added dall-e, reworked bot, added nip89config

This commit is contained in:
Believethehype
2023-11-24 17:20:29 +01:00
parent 7c533ec439
commit 215916c1ef
16 changed files with 410 additions and 99 deletions

20
main.py
View File

@@ -1,4 +1,7 @@
import os
import signal
import sys
import time
from pathlib import Path
from threading import Thread
@@ -6,7 +9,7 @@ import dotenv
from nostr_sdk import Keys
from bot import Bot
from playground import build_pdf_extractor, build_translator, build_unstable_diffusion, build_sketcher
from playground import build_pdf_extractor, build_translator, build_unstable_diffusion, build_sketcher, build_dalle
from utils.dvmconfig import DVMConfig
@@ -34,6 +37,9 @@ def run_nostr_dvm_with_local_config():
sketcher = build_sketcher("Sketcher", [bot_publickey])
sketcher.run()
dalle = build_dalle("Dall-E 3", [bot_publickey])
dalle.run()
# We will run an optional bot that can communicate with the DVMs
# Note this is very basic for now and still under development
bot_config = DVMConfig()
@@ -41,20 +47,26 @@ def run_nostr_dvm_with_local_config():
bot_config.LNBITS_INVOICE_KEY = os.getenv("LNBITS_INVOICE_KEY")
bot_config.LNBITS_URL = os.getenv("LNBITS_HOST")
# Finally we add some of the DVMs we created before to the Bot and start it.
bot_config.SUPPORTED_DVMS = [sketcher, unstable_artist, translator]
bot_config.SUPPORTED_DVMS = [sketcher, unstable_artist, dalle, translator]
bot = Bot
nostr_dvm_thread = Thread(target=bot, args=[bot_config])
nostr_dvm_thread.start()
# Keep the main function alive for libraries like openai
try:
while True:
time.sleep(10)
except KeyboardInterrupt:
print('Stay weird!')
os.kill(os.getpid(), signal.SIGKILL)
if __name__ == '__main__':
env_path = Path('.env')
if env_path.is_file():
print(f'loading environment from {env_path.resolve()}')
dotenv.load_dotenv(env_path, verbose=True, override=True)
else:
raise FileNotFoundError(f'.env file not found at {env_path} ')
run_nostr_dvm_with_local_config()