This commit is contained in:
Believethehype 2023-11-21 11:39:36 +01:00
parent 27aa132ec9
commit 645fff6284
3 changed files with 22 additions and 22 deletions

View File

@ -13,9 +13,6 @@ A tutorial on how to add additional tasks, as well as the larger server backend
Known Issues:
- After refactoring DVMs work independent from each other for the most part.
- They currently still share a joblist and might act weird together (TODO rework joblist)
- Probably therefore jobs might sometimes not start (need investigation)
- Some functions might work easier than they did before (need some refactoring)
- Bot currently not implemented
- Some basic functionality is still missing, e.g. handling various mediasources

View File

@ -11,8 +11,9 @@ from utils.output_utils import uploadMediaToHoster
"""
This file contains basic calling functions for ML tasks that are outsourced to nova-server
(https://github.com/hcmlab/nova-server). nova-server is an Open-Source backend that enables running models locally, by
accepting a request form. Modules are deployed in in separate virtual environments so dependencies won't conflict.
(https://github.com/hcmlab/nova-server). nova-server is an Open-Source backend that enables running models locally
based on preefined modules (nova-server-modules), by accepting a request form.
Modules are deployed in in separate virtual environments so dependencies won't conflict.
Setup nova-server:
https://hcmlab.github.io/nova-server/docbuild/html/tutorials/introduction.html
@ -20,7 +21,7 @@ https://hcmlab.github.io/nova-server/docbuild/html/tutorials/introduction.html
"""
"""
send_request_to_nova_server(request_form)
send_request_to_nova_server(request_form, address)
Function to send a request_form to the server, containing all the information we parsed from the Nostr event and added
in the module that is calling the server
@ -36,7 +37,7 @@ def send_request_to_nova_server(request_form, address):
"""
check_nova_server_status(request_form)
check_nova_server_status(request_form, address)
Function that requests the status of the current process with the jobID (we use the Nostr event as jobID).
When the Job is successfully finished we grab the result and depending on the type return the output
We throw an exception on error

32
main.py
View File

@ -30,10 +30,10 @@ def run_nostr_dvm_with_local_config():
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"
".jpg\",\"about\":\"I extract Text from pdf documents\","
"\"nip90Params\":{}}")
content = ("{\"name\":\"" + pdfextactor.NAME + "\","
"\"image\":\"https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg\","
"\"about\":\"I extract Text from pdf documents\","
"\"nip90Params\":{}}")
dvm_config.NIP89 = pdfextactor.NIP89_announcement(d_tag, content)
# Spawn DVM2 Kind 5002 Text Translation
@ -44,11 +44,10 @@ def run_nostr_dvm_with_local_config():
translator = Translation("Translator", dvm_config)
d_tag = os.getenv(env.TASK_TRANSLATION_NIP89_DTAG)
content = "{\"name\":\"" + translator.NAME + ("\",\"image\":\"https://image.nostr.build"
"/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669"
".jpg\",\"about\":\"I translate text from given text/event/job, "
"currently using Google Translation Services into language defined "
"in param. \",\"nip90Params\":{\"language\":{\"required\":true,"
content = ("{\"name\":\"" + translator.NAME + "\","
"\"image\":\"https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg\","
"\"about\":\"I translate text from given text/event/job, ""currently using Google Translation Services into language defined in params.\","
"\"nip90Params\":{\"language\":{\"required\":true,"
"\"values\":[\"af\",\"am\",\"ar\",\"az\",\"be\",\"bg\",\"bn\","
"\"bs\",\"ca\",\"ceb\",\"co\",\"cs\",\"cy\",\"da\",\"de\",\"el\","
"\"eo\",\"es\",\"et\",\"eu\",\"fa\",\"fi\",\"fr\",\"fy\",\"ga\","
@ -72,9 +71,10 @@ def run_nostr_dvm_with_local_config():
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\":{}}")
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.NIP89 = unstableartist.NIP89_announcement(d_tag, content)
@ -86,9 +86,11 @@ def run_nostr_dvm_with_local_config():
#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\":{}}")
content = ("{\"name\":\"" + unstableartist.NAME + "\","
"\"image\":\"https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg\","
"\"about\":\"I draw images based on a prompt with a Model called unstable diffusion.\","
"\"nip90Params\":{}}")
dvm_config.NIP89 = sketcher.NIP89_announcement(d_tag, content)