From abae1a911b1590def570e4c39a7e797501b8109c Mon Sep 17 00:00:00 2001 From: Believethehype Date: Fri, 15 Dec 2023 10:27:53 +0100 Subject: [PATCH] simplyfiy nip89 --- nostr_dvm/tasks/advanced_search.py | 45 +++++++++---------- nostr_dvm/tasks/convert_media.py | 13 +++--- nostr_dvm/tasks/discovery_inactive_follows.py | 26 +++++------ .../tasks/imagegeneration_openai_dalle.py | 13 +++--- .../tasks/imagegeneration_replicate_sdxl.py | 13 +++--- nostr_dvm/tasks/textextraction_google.py | 13 +++--- nostr_dvm/tasks/textextraction_pdf.py | 3 +- nostr_dvm/tasks/textgeneration_llmlite.py | 13 +++--- nostr_dvm/tasks/translation_google.py | 25 +++++------ nostr_dvm/tasks/translation_libretranslate.py | 26 +++++------ nostr_dvm/tasks/trending_notes_nostrband.py | 5 +-- .../tasks/videogeneration_replicate_svd.py | 4 +- 12 files changed, 93 insertions(+), 106 deletions(-) diff --git a/nostr_dvm/tasks/advanced_search.py b/nostr_dvm/tasks/advanced_search.py index 1cd3ad9..79b51be 100644 --- a/nostr_dvm/tasks/advanced_search.py +++ b/nostr_dvm/tasks/advanced_search.py @@ -139,35 +139,34 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS # Add NIP89 - nip90params = { - "user": { - "required": False, - "values": [], - "description": "Do the task for another user" - }, - "since": { - "required": False, - "values": [], - "description": "The number of days in the past from now the search should include" - }, - "until": { - "required": False, - "values": [], - "description": "The number of days in the past from now the search should include up to" - }, - "max_results": { - "required": False, - "values": [], - "description": "The number of maximum results to return (default currently 20)" - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I search notes", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "user": { + "required": False, + "values": [], + "description": "Do the task for another user" + }, + "since": { + "required": False, + "values": [], + "description": "The number of days in the past from now the search should include" + }, + "until": { + "required": False, + "values": [], + "description": "The number of days in the past from now the search should include up to" + }, + "max_results": { + "required": False, + "values": [], + "description": "The number of maximum results to return (default currently 20)" + } + } } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/convert_media.py b/nostr_dvm/tasks/convert_media.py index e3a0ba1..b52217c 100644 --- a/nostr_dvm/tasks/convert_media.py +++ b/nostr_dvm/tasks/convert_media.py @@ -85,19 +85,18 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS # Add NIP89 - nip90params = { - "media_format": { - "required": False, - "values": ["video/mp4", "audio/mp3"] - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I convert videos from urls to given output format.", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "media_format": { + "required": False, + "values": ["video/mp4", "audio/mp3"] + } + } } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/discovery_inactive_follows.py b/nostr_dvm/tasks/discovery_inactive_follows.py index 6fe3564..9db7260 100644 --- a/nostr_dvm/tasks/discovery_inactive_follows.py +++ b/nostr_dvm/tasks/discovery_inactive_follows.py @@ -172,26 +172,24 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS # Add NIP89 - nip90params = { - "user": { - "required": False, - "values": [], - "description": "Do the task for another user" - }, - "since_days": { - "required": False, - "values": [], - "description": "The number of days a user has not been active to be considered inactive" - - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I discover users you follow, but that have been inactive on Nostr", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "user": { + "required": False, + "values": [], + "description": "Do the task for another user" + }, + "since_days": { + "required": False, + "values": [], + "description": "The number of days a user has not been active to be considered inactive" + } + } } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/imagegeneration_openai_dalle.py b/nostr_dvm/tasks/imagegeneration_openai_dalle.py index 480a47d..52a2636 100644 --- a/nostr_dvm/tasks/imagegeneration_openai_dalle.py +++ b/nostr_dvm/tasks/imagegeneration_openai_dalle.py @@ -130,19 +130,18 @@ def build_example(name, identifier, admin_config): cost_in_cent = 4.0 dvm_config.FIX_COST = int(((cost_in_cent / (get_price_per_sat("USD") * 100)) + profit_in_sats)) - nip90params = { - "size": { - "required": False, - "values": ["1024:1024", "1024x1792", "1792x1024"] - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use OpenAI's DALLĀ·E 3", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "size": { + "required": False, + "values": ["1024:1024", "1024x1792", "1792x1024"] + } + } } diff --git a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py index 5be5a96..c16e275 100644 --- a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py +++ b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py @@ -125,19 +125,18 @@ def build_example(name, identifier, admin_config): profit_in_sats = 10 dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats)) - nip90params = { - "size": { - "required": False, - "values": ["1024:1024", "1024x1792", "1792x1024"] - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run StableDiffusion XL", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "size": { + "required": False, + "values": ["1024:1024", "1024x1792", "1792x1024"] + } + } } diff --git a/nostr_dvm/tasks/textextraction_google.py b/nostr_dvm/tasks/textextraction_google.py index 6532787..a226558 100644 --- a/nostr_dvm/tasks/textextraction_google.py +++ b/nostr_dvm/tasks/textextraction_google.py @@ -136,19 +136,18 @@ def build_example(name, identifier, admin_config): # A module might have options it can be initialized with, here we set a default model, and the nova-server # address it should use. These parameters can be freely defined in the task component - nip90params = { - "language": { - "required": False, - "values": ["en-US"] - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I extract text from media files with the Google API. I understand English by default", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "language": { + "required": False, + "values": ["en-US"] + } + } } nip89config = NIP89Config() nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, diff --git a/nostr_dvm/tasks/textextraction_pdf.py b/nostr_dvm/tasks/textextraction_pdf.py index 57db6c7..e9062cf 100644 --- a/nostr_dvm/tasks/textextraction_pdf.py +++ b/nostr_dvm/tasks/textextraction_pdf.py @@ -101,14 +101,13 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS # Add NIP89 - nip90params = {} nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I extract text from pdf documents. I only support Latin letters", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": {} } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/textgeneration_llmlite.py b/nostr_dvm/tasks/textgeneration_llmlite.py index b87cb13..adf7a9c 100644 --- a/nostr_dvm/tasks/textgeneration_llmlite.py +++ b/nostr_dvm/tasks/textgeneration_llmlite.py @@ -102,19 +102,18 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS - nip90params = { - "size": { - "required": False, - "values": ["1024:1024", "1024x1792", "1792x1024"] - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use a LLM connected via OLLAMA", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "size": { + "required": False, + "values": ["1024:1024", "1024x1792", "1792x1024"] + } + } } options = {'default_model': "ollama/llama2-uncensored", 'server': "http://localhost:11434"} diff --git a/nostr_dvm/tasks/translation_google.py b/nostr_dvm/tasks/translation_google.py index a3bd201..73b5462 100644 --- a/nostr_dvm/tasks/translation_google.py +++ b/nostr_dvm/tasks/translation_google.py @@ -115,18 +115,6 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS - nip90params = { - "language": { - "required": False, - "values": ["en", "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"] - } - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", @@ -134,7 +122,18 @@ def build_example(name, identifier, admin_config): "input into the language defined in params.", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "language": { + "required": False, + "values": ["en", "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"] + } + } } nip89config = NIP89Config() nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, diff --git a/nostr_dvm/tasks/translation_libretranslate.py b/nostr_dvm/tasks/translation_libretranslate.py index 6989272..0b7ebc1 100644 --- a/nostr_dvm/tasks/translation_libretranslate.py +++ b/nostr_dvm/tasks/translation_libretranslate.py @@ -114,18 +114,7 @@ def build_example(name, identifier, admin_config): options = {'libre_end_point': os.getenv("LIBRE_TRANSLATE_ENDPOINT"), 'libre_api_key': os.getenv("LIBRE_TRANSLATE_API_KEY")} - nip90params = { - "language": { - "required": False, - "values": ["en", "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"] - } - } + nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", @@ -133,7 +122,18 @@ def build_example(name, identifier, admin_config): "input into the language defined in params.", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": { + "language": { + "required": False, + "values": ["en", "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"] + } + } } nip89config = NIP89Config() nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, diff --git a/nostr_dvm/tasks/trending_notes_nostrband.py b/nostr_dvm/tasks/trending_notes_nostrband.py index 8bd3df8..82d48f7 100644 --- a/nostr_dvm/tasks/trending_notes_nostrband.py +++ b/nostr_dvm/tasks/trending_notes_nostrband.py @@ -105,15 +105,14 @@ def build_example(name, identifier, admin_config): dvm_config = build_default_config(identifier) admin_config.LUD16 = dvm_config.LN_ADDRESS # Add NIP89 - nip90params = { - } + nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I show trending notes from nostr.band", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": {} } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/videogeneration_replicate_svd.py b/nostr_dvm/tasks/videogeneration_replicate_svd.py index c43c531..5331cbc 100644 --- a/nostr_dvm/tasks/videogeneration_replicate_svd.py +++ b/nostr_dvm/tasks/videogeneration_replicate_svd.py @@ -117,15 +117,13 @@ def build_example(name, identifier, admin_config): cost_in_cent = 4.0 dvm_config.FIX_COST = int(((cost_in_cent / (get_price_per_sat("USD") * 100)) + profit_in_sats)) - nip90params = { - } nip89info = { "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run StableDiffusion XL", "encryptionSupported": True, "cashuAccepted": True, - "nip90Params": nip90params + "nip90Params": {} }