mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-11 01:32:30 +02:00
add second task, pdf-to-text
example for kind 5000 event
This commit is contained in:
22
main.py
22
main.py
@@ -11,21 +11,29 @@ def run_nostr_dvm_with_local_config():
|
||||
from dvm import dvm, DVMConfig
|
||||
from utils.nip89_utils import NIP89Announcement
|
||||
|
||||
|
||||
dvmconfig = DVMConfig()
|
||||
dvmconfig.PRIVATE_KEY = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
dvmconfig.SUPPORTED_TASKS = ["translation"]
|
||||
dvmconfig.SUPPORTED_TASKS = ["translation", "pdf-to-text"]
|
||||
dvmconfig.LNBITS_INVOICE_KEY = os.getenv(env.LNBITS_INVOICE_KEY)
|
||||
dvmconfig.LNBITS_URL = os.getenv(env.LNBITS_HOST)
|
||||
|
||||
# In admin_utils, set rebroadcast_nip89 to true to (re)broadcast your DVM. You can create a valid dtag and the content on vendata.io
|
||||
# Add the dtag in your .env file so you can update your dvm later and change the content here as needed.
|
||||
|
||||
nip89extraction = NIP89Announcement()
|
||||
nip89extraction.kind = EventDefinitions.KIND_NIP90_EXTRACT_TEXT
|
||||
nip89extraction.dtag = os.getenv(env.TASK_TRANSLATION_NIP89_DTAG)
|
||||
nip89extraction.pk = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
nip89extraction.content = "{\"name\":\"Pdf Extractor\",\"image\":\"https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg\",\"about\":\"I extract Text from pdf documents\",\"nip90Params\":{}}"
|
||||
dvmconfig.NIP89s.append(nip89extraction)
|
||||
|
||||
nip89translation = NIP89Announcement()
|
||||
nip89translation.kind = EventDefinitions.KIND_NIP90_TRANSLATE_TEXT
|
||||
nip89translation.dtag = os.getenv(env.TASK_TRANSLATION_NIP89_DTAG)
|
||||
nip89translation.pk = os.getenv(env.NOSTR_PRIVATE_KEY)
|
||||
nip89translation.content = "{\"name\":\"NostrAI DVM Translator\",\"image\":\"https://cdn.nostr.build/i/feb98d8700abe7d6c67d9106a72a20354bf50805af79869638f5a32d24a5ac2a.jpg\",\"about\":\"Translates Text from given text/event/job, currently using Google Translation Services into language defined in param. \",\"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\",\"gd\",\"gl\",\"gu\",\"ha\",\"haw\",\"hi\",\"hmn\",\"hr\",\"ht\",\"hu\",\"hy\",\"id\",\"ig\",\"is\",\"it\",\"he\",\"ja\",\"jv\",\"ka\",\"kk\",\"km\",\"kn\",\"ko\",\"ku\",\"ky\",\"la\",\"lb\",\"lo\",\"lt\",\"lv\",\"mg\",\"mi\",\"mk\",\"ml\",\"mn\",\"mr\",\"ms\",\"mt\",\"my\",\"ne\",\"nl\",\"no\",\"ny\",\"or\",\"pa\",\"pl\",\"ps\",\"pt\",\"ro\",\"ru\",\"sd\",\"si\",\"sk\",\"sl\",\"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\"]}}}"
|
||||
nip89translation.content = "{\"name\":\"Translator\",\"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,\"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\",\"gd\",\"gl\",\"gu\",\"ha\",\"haw\",\"hi\",\"hmn\",\"hr\",\"ht\",\"hu\",\"hy\",\"id\",\"ig\",\"is\",\"it\",\"he\",\"ja\",\"jv\",\"ka\",\"kk\",\"km\",\"kn\",\"ko\",\"ku\",\"ky\",\"la\",\"lb\",\"lo\",\"lt\",\"lv\",\"mg\",\"mi\",\"mk\",\"ml\",\"mn\",\"mr\",\"ms\",\"mt\",\"my\",\"ne\",\"nl\",\"no\",\"ny\",\"or\",\"pa\",\"pl\",\"ps\",\"pt\",\"ro\",\"ru\",\"sd\",\"si\",\"sk\",\"sl\",\"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\"]}}}"
|
||||
dvmconfig.NIP89s.append(nip89translation)
|
||||
|
||||
|
||||
nostr_dvm_thread = Thread(target=dvm, args=[dvmconfig])
|
||||
nostr_dvm_thread.start()
|
||||
|
||||
@@ -39,10 +47,4 @@ if __name__ == '__main__':
|
||||
else:
|
||||
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||
|
||||
|
||||
|
||||
run_nostr_dvm_with_local_config()
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user