mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-11 00:12:28 +02:00
rebuild so each dvm runs on its own.
This commit is contained in:
62
main.py
62
main.py
@@ -8,19 +8,22 @@ from tasks.imagegenerationsdxl import ImageGenerationSDXL
|
||||
from tasks.textextractionpdf import TextExtractionPDF
|
||||
from tasks.translation import Translation
|
||||
|
||||
|
||||
def run_nostr_dvm_with_local_config():
|
||||
from dvm import DVM, DVMConfig
|
||||
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
|
||||
# Spawn the DVMs
|
||||
# Add NIP89 events for each DVM (set rebroad_cast = True for the next start in admin_utils)
|
||||
# Add NIP89 events for each DVM (set rebroadcast = True for the next start in admin_utils)
|
||||
# Add the dtag here or in your .env file, so you can update your dvm later and change the content as needed.
|
||||
# Get a dtag and the content at vendata.io
|
||||
|
||||
# Spawn DVM1 Kind 5000 Text Ectractor from PDFs
|
||||
pdfextactor = TextExtractionPDF("PDF Extractor", os.getenv(env.NOSTR_PRIVATE_KEY))
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
dvm_config.LNBITS_INVOICE_KEY = os.getenv(env.LNBITS_INVOICE_KEY)
|
||||
dvm_config.LNBITS_URL = os.getenv(env.LNBITS_HOST)
|
||||
|
||||
pdfextactor = TextExtractionPDF("PDF Extractor", dvm_config)
|
||||
d_tag = os.getenv(env.TASK_TEXTEXTRACTION_NIP89_DTAG)
|
||||
content = "{\"name\":\"" + pdfextactor.NAME + ("\",\"image\":\"https://image.nostr.build"
|
||||
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669"
|
||||
@@ -29,7 +32,13 @@ def run_nostr_dvm_with_local_config():
|
||||
dvm_config.NIP89s.append(pdfextactor.NIP89_announcement(d_tag, content))
|
||||
|
||||
# Spawn DVM2 Kind 5002 Text Translation
|
||||
translator = Translation("Translator", os.getenv(env.NOSTR_PRIVATE_KEY))
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
dvm_config.LNBITS_INVOICE_KEY = os.getenv(env.LNBITS_INVOICE_KEY)
|
||||
dvm_config.LNBITS_URL = os.getenv(env.LNBITS_HOST)
|
||||
|
||||
translator = Translation("Translator", dvm_config)
|
||||
|
||||
d_tag = os.getenv(env.TASK_TRANSLATION_NIP89_DTAG)
|
||||
content = "{\"name\":\"" + translator.NAME + ("\",\"image\":\"https://image.nostr.build"
|
||||
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669"
|
||||
@@ -48,31 +57,36 @@ def run_nostr_dvm_with_local_config():
|
||||
"\"sm\",\"sn\",\"so\",\"sq\",\"sr\",\"st\",\"su\",\"sv\",\"sw\","
|
||||
"\"ta\",\"te\",\"tg\",\"th\",\"tl\",\"tr\",\"ug\",\"uk\",\"ur\","
|
||||
"\"uz\",\"vi\",\"xh\",\"yi\",\"yo\",\"zh\",\"zu\"]}}}")
|
||||
|
||||
dvm_config.NIP89s.append(translator.NIP89_announcement(d_tag, content))
|
||||
|
||||
# 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
|
||||
artist = ImageGenerationSDXL("Unstable Diffusion", os.getenv(env.NOSTR_PRIVATE_KEY))
|
||||
d_tag = os.getenv(env.TASK_IMAGEGENERATION_NIP89_DTAG)
|
||||
content = "{\"name\":\"" + artist.NAME + ("\",\"image\":\"https://image.nostr.build"
|
||||
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg"
|
||||
"\",\"about\":\"I draw images based on a prompt with Stable Diffusion "
|
||||
"XL 1.0.\",\"nip90Params\":{}}")
|
||||
dvm_config.NIP89s.append(artist.NIP89_announcement(d_tag, content))
|
||||
|
||||
|
||||
|
||||
# Add the DVMS you want to use to the config
|
||||
dvm_config.SUPPORTED_TASKS = [pdfextactor, translator, artist]
|
||||
|
||||
# SET Lnbits Invoice Key and Server if DVM should provide invoices directly, else make sure you have a lnaddress
|
||||
# on the profile
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
dvm_config.LNBITS_INVOICE_KEY = os.getenv(env.LNBITS_INVOICE_KEY)
|
||||
dvm_config.LNBITS_URL = os.getenv(env.LNBITS_HOST)
|
||||
|
||||
# Start the Server
|
||||
nostr_dvm_thread = Thread(target=DVM, args=[dvm_config])
|
||||
nostr_dvm_thread.start()
|
||||
unstableartist = ImageGenerationSDXL("Unstable Diffusion", dvm_config, "unstable")
|
||||
d_tag = os.getenv(env.TASK_IMAGEGENERATION_NIP89_DTAG)
|
||||
content = "{\"name\":\"" + unstableartist.NAME + ("\",\"image\":\"https://image.nostr.build"
|
||||
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg"
|
||||
"\",\"about\":\"I draw images based on a prompt with a Model called unstable diffusion.\",\"nip90Params\":{}}")
|
||||
dvm_config.NIP89s.append(unstableartist.NIP89_announcement(d_tag, content))
|
||||
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = "73b262d31edc6ea1316dffcc7daa772651d661e6475761b7b78291482c1bf5cb"
|
||||
dvm_config.LNBITS_INVOICE_KEY = os.getenv(env.LNBITS_INVOICE_KEY)
|
||||
dvm_config.LNBITS_URL = os.getenv(env.LNBITS_HOST)
|
||||
|
||||
# Spawn another Instance of text-to-image but use a different model and lora this time.
|
||||
|
||||
sketcher = ImageGenerationSDXL("Sketcher", dvm_config, "mohawk", "timburton")
|
||||
d_tag = os.getenv(env.TASK_IMAGEGENERATION_NIP89_DTAG2)
|
||||
content = "{\"name\":\"" + sketcher.NAME + ("\",\"image\":\"https://image.nostr.build"
|
||||
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg"
|
||||
"\",\"about\":\"I draw images based on a prompt in kind of Tim Burton style\",\"nip90Params\":{}}")
|
||||
dvm_config.NIP89s.append(sketcher.NIP89_announcement(d_tag, content))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user