mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-11 09:03:20 +02:00
move nserver to branch for now
This commit is contained in:
77
main.py
77
main.py
@@ -11,11 +11,8 @@ from interfaces.dvmtaskinterface import DVMTaskInterface
|
||||
import tasks.convert_media as convert_media
|
||||
import tasks.discovery_inactive_follows as discovery_inactive_follows
|
||||
import tasks.imagegeneration_openai_dalle as imagegeneration_openai_dalle
|
||||
import tasks.imagegeneration_sdxl as imagegeneration_sdxl
|
||||
import tasks.imagegeneration_sdxlimg2img as imagegeneration_sdxlimg2img
|
||||
import tasks.textextraction_pdf as textextraction_pdf
|
||||
import tasks.textextraction_google as textextraction_google
|
||||
import tasks.textextraction_whisperx as textextraction_whisperx
|
||||
import tasks.translation_google as translation_google
|
||||
import tasks.translation_libretranslate as translation_libretranslate
|
||||
|
||||
@@ -70,80 +67,6 @@ def playground():
|
||||
bot_config.SUPPORTED_DVMS.append(libre_translator) # We add translator to the bot
|
||||
libre_translator.run()
|
||||
|
||||
# Spawn DVM3 Kind 5100 Image Generation This one uses a specific backend called nova-server.
|
||||
# If you want to use it, see the instructions in backends/nova_server
|
||||
if os.getenv("NOVA_SERVER") is not None and os.getenv("NOVA_SERVER") != "":
|
||||
stable_artist = imagegeneration_sdxl.build_example("Stable Diffusion XL", "stable_diffusion",
|
||||
admin_config, os.getenv("NOVA_SERVER"),
|
||||
"stabilityai/stable-diffusion-xl",
|
||||
"")
|
||||
bot_config.SUPPORTED_DVMS.append(stable_artist) # We add unstable Diffusion to the bot
|
||||
stable_artist.run()
|
||||
|
||||
# Spawn DVM4, another Instance of text-to-image, as before but use a different privatekey, model and lora this time.
|
||||
if os.getenv("NOVA_SERVER") is not None and os.getenv("NOVA_SERVER") != "":
|
||||
# Let's not use one of the examples in this one, but generate our own variation of the dvm. We make a new DVM
|
||||
# called "Sketcher", with a predefined model and lora, so it will always make sketches of prompts
|
||||
def build_sketcher(name, identifier, admin_config):
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = check_and_set_private_key(identifier)
|
||||
dvm_config.LNBITS_INVOICE_KEY = os.getenv("LNBITS_INVOICE_KEY")
|
||||
dvm_config.LNBITS_URL = os.getenv("LNBITS_HOST")
|
||||
|
||||
nip90params = {
|
||||
"negative_prompt": {
|
||||
"required": False,
|
||||
"values": []
|
||||
},
|
||||
"ratio": {
|
||||
"required": False,
|
||||
"values": ["1:1", "4:3", "16:9", "3:4", "9:16", "10:16"]
|
||||
}
|
||||
}
|
||||
nip89info = {
|
||||
"name": name,
|
||||
"image": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg",
|
||||
"about": "I draw images based on a prompt in the style of paper sketches",
|
||||
"encryptionSupported": True,
|
||||
"cashuAccepted": True,
|
||||
"nip90Params": nip90params
|
||||
}
|
||||
|
||||
# A module might have options it can be initialized with, here we set a default model, lora and the nova-server
|
||||
# address it should use. These parameters can be freely defined in the task component
|
||||
options = {'default_model': "mohawk", 'default_lora': "timburton", 'nova_server': os.getenv("NOVA_SERVER")}
|
||||
|
||||
nip89config = NIP89Config()
|
||||
nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
|
||||
nip89info["image"])
|
||||
nip89config.CONTENT = json.dumps(nip89info)
|
||||
# We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
|
||||
return imagegeneration_sdxl.ImageGenerationSDXL(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||
admin_config=admin_config, options=options)
|
||||
|
||||
sketcher = build_sketcher("Sketcher", "sketcher", admin_config)
|
||||
bot_config.SUPPORTED_DVMS.append(sketcher) # We also add Sketcher to the bot
|
||||
sketcher.run()
|
||||
|
||||
# Spawn DVM5, image-to-image, .
|
||||
if os.getenv("NOVA_SERVER") is not None and os.getenv("NOVA_SERVER") != "":
|
||||
imageconverter = imagegeneration_sdxlimg2img.build_example("Image Converter Inkpunk",
|
||||
"image_converter_inkpunk", admin_config,
|
||||
os.getenv("NOVA_SERVER"),
|
||||
"inkpunk", 0.6)
|
||||
bot_config.SUPPORTED_DVMS.append(imageconverter) # We also add Sketcher to the bot
|
||||
imageconverter.run()
|
||||
|
||||
# Spawn DVM5, Another script on nova-server calling WhisperX to transcribe media files
|
||||
|
||||
if os.getenv("NOVA_SERVER") is not None and os.getenv("NOVA_SERVER") != "":
|
||||
whisperer = textextraction_whisperx.build_example("Whisperer", "whisperx", admin_config, os.getenv("NOVA_SERVER"))
|
||||
bot_config.SUPPORTED_DVMS.append(whisperer) # We also add Sketcher to the bot
|
||||
whisperer.run()
|
||||
|
||||
transcriptor = textextraction_google.build_example("Transcriptor", "speech_recognition", admin_config)
|
||||
bot_config.SUPPORTED_DVMS.append(transcriptor) # We also add Sketcher to the bot
|
||||
transcriptor.run()
|
||||
|
||||
# Spawn DVM6, this one requires an OPENAI API Key and balance with OpenAI, you will move the task to them and pay
|
||||
# per call. Make sure you have enough balance and the DVM's cost is set higher than what you pay yourself, except, you know,
|
||||
|
Reference in New Issue
Block a user