add adminconfig per dvm

This commit is contained in:
Believethehype
2023-11-21 11:11:12 +01:00
parent 50f4076416
commit 27aa132ec9
9 changed files with 83 additions and 48 deletions

28
main.py
View File

@@ -6,17 +6,23 @@ import utils.env as env
from tasks.imagegenerationsdxl import ImageGenerationSDXL
from tasks.textextractionpdf import TextExtractionPDF
from tasks.translation import Translation
from utils.admin_utils import AdminConfig
from utils.dvmconfig import DVMConfig
def run_nostr_dvm_with_local_config():
from utils.dvmconfig import DVMConfig
#Generate a optional Admin Config, in this case, whenever we give our DVMS this config, they will (re)broadcast
# their NIP89 announcement
admin_config = AdminConfig()
admin_config.REBROADCASTNIP89 = True
# Spawn the DVMs
# Add NIP89 events for each DVM (set rebroadcast = True for the next start in admin_utils)
# Add NIP89 events for each DVM
# 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
# Spawn DVM1 Kind 5000 Text Extractor from PDFs
dvm_config = DVMConfig()
dvm_config.PRIVATE_KEY = os.getenv(env.NOSTR_PRIVATE_KEY)
dvm_config.LNBITS_INVOICE_KEY = os.getenv(env.LNBITS_INVOICE_KEY)
@@ -28,7 +34,7 @@ def run_nostr_dvm_with_local_config():
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669"
".jpg\",\"about\":\"I extract Text from pdf documents\","
"\"nip90Params\":{}}")
dvm_config.NIP89s.append(pdfextactor.NIP89_announcement(d_tag, content))
dvm_config.NIP89 = pdfextactor.NIP89_announcement(d_tag, content)
# Spawn DVM2 Kind 5002 Text Translation
dvm_config = DVMConfig()
@@ -37,7 +43,6 @@ def run_nostr_dvm_with_local_config():
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"
@@ -57,7 +62,7 @@ def run_nostr_dvm_with_local_config():
"\"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))
dvm_config.NIP89 = 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
@@ -65,25 +70,26 @@ def run_nostr_dvm_with_local_config():
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)
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.NIP89 = unstableartist.NIP89_announcement(d_tag, content)
# Spawn another Instance of text-to-image but use a different model and lora this time.
# Spawn another Instance of text-to-image but use a different privatekey, model and lora this time.
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)
sketcher = ImageGenerationSDXL("Sketcher", dvm_config, "mohawk", "timburton")
#We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
sketcher = ImageGenerationSDXL("Sketcher", dvm_config, admin_config, default_model="mohawk", default_lora="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))
dvm_config.NIP89 = sketcher.NIP89_announcement(d_tag, content)
if __name__ == '__main__':