diff --git a/nostr_dvm/interfaces/dvmtaskinterface.py b/nostr_dvm/interfaces/dvmtaskinterface.py index b4f720c..5deaf3c 100644 --- a/nostr_dvm/interfaces/dvmtaskinterface.py +++ b/nostr_dvm/interfaces/dvmtaskinterface.py @@ -94,7 +94,7 @@ class DVMTaskInterface: nip89.CONTENT = nip89config.CONTENT return nip89 - def is_input_supported(self, tags) -> bool: + def is_input_supported(self, tags, client=None, dvm_config=None) -> bool: """Check if input is supported for current Task.""" pass diff --git a/nostr_dvm/tasks/advanced_search.py b/nostr_dvm/tasks/advanced_search.py index 2b11a08..75af26d 100644 --- a/nostr_dvm/tasks/advanced_search.py +++ b/nostr_dvm/tasks/advanced_search.py @@ -30,7 +30,7 @@ class AdvancedSearch(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/convert_media.py b/nostr_dvm/tasks/convert_media.py index 970bbc9..735fc00 100644 --- a/nostr_dvm/tasks/convert_media.py +++ b/nostr_dvm/tasks/convert_media.py @@ -28,7 +28,7 @@ class MediaConverter(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/discovery_inactive_follows.py b/nostr_dvm/tasks/discovery_inactive_follows.py index 964c0ef..9ca8653 100644 --- a/nostr_dvm/tasks/discovery_inactive_follows.py +++ b/nostr_dvm/tasks/discovery_inactive_follows.py @@ -33,7 +33,7 @@ class DiscoverInactiveFollows(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): # no input required return True diff --git a/nostr_dvm/tasks/imagegeneration_openai_dalle.py b/nostr_dvm/tasks/imagegeneration_openai_dalle.py index fc03938..8dd584e 100644 --- a/nostr_dvm/tasks/imagegeneration_openai_dalle.py +++ b/nostr_dvm/tasks/imagegeneration_openai_dalle.py @@ -34,7 +34,7 @@ class ImageGenerationDALLE(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py index 5912560..b76639b 100644 --- a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py +++ b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py @@ -33,7 +33,7 @@ class ImageGenerationReplicateSDXL(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/imagegeneration_sd21_mlx.py b/nostr_dvm/tasks/imagegeneration_sd21_mlx.py index 11de72c..5524958 100644 --- a/nostr_dvm/tasks/imagegeneration_sd21_mlx.py +++ b/nostr_dvm/tasks/imagegeneration_sd21_mlx.py @@ -37,7 +37,7 @@ class ImageGenerationMLX(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/imagegeneration_sdxl.py b/nostr_dvm/tasks/imagegeneration_sdxl.py index 532ab09..1a2704a 100644 --- a/nostr_dvm/tasks/imagegeneration_sdxl.py +++ b/nostr_dvm/tasks/imagegeneration_sdxl.py @@ -27,7 +27,7 @@ class ImageGenerationSDXL(DVMTaskInterface): admin_config: AdminConfig = None, options=None): super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py b/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py index 1fdf30c..f9d7b44 100644 --- a/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py +++ b/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py @@ -27,7 +27,7 @@ class ImageGenerationSDXLIMG2IMG(DVMTaskInterface): admin_config: AdminConfig = None, options=None): super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): hasurl = False hasprompt = False for tag in tags: diff --git a/nostr_dvm/tasks/imageinterrogator.py b/nostr_dvm/tasks/imageinterrogator.py index 1bc9390..b37cca7 100644 --- a/nostr_dvm/tasks/imageinterrogator.py +++ b/nostr_dvm/tasks/imageinterrogator.py @@ -26,7 +26,7 @@ class ImageInterrogator(DVMTaskInterface): admin_config: AdminConfig = None, options=None): super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): hasurl = False for tag in tags: if tag.as_vec()[0] == 'i': diff --git a/nostr_dvm/tasks/imageupscale.py b/nostr_dvm/tasks/imageupscale.py index 0133fdc..a49f5da 100644 --- a/nostr_dvm/tasks/imageupscale.py +++ b/nostr_dvm/tasks/imageupscale.py @@ -26,7 +26,7 @@ class ImageUpscale(DVMTaskInterface): admin_config: AdminConfig = None, options=None): super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): hasurl = False for tag in tags: if tag.as_vec()[0] == 'i': diff --git a/nostr_dvm/tasks/textextraction_google.py b/nostr_dvm/tasks/textextraction_google.py index 23053df..d71e2a6 100644 --- a/nostr_dvm/tasks/textextraction_google.py +++ b/nostr_dvm/tasks/textextraction_google.py @@ -33,7 +33,7 @@ class SpeechToTextGoogle(DVMTaskInterface): if options is None: options = {} - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/textextraction_pdf.py b/nostr_dvm/tasks/textextraction_pdf.py index b993097..0e4b1b6 100644 --- a/nostr_dvm/tasks/textextraction_pdf.py +++ b/nostr_dvm/tasks/textextraction_pdf.py @@ -30,7 +30,7 @@ class TextExtractionPDF(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/textextraction_whisperx.py b/nostr_dvm/tasks/textextraction_whisperx.py index 13e998a..dfc62c8 100644 --- a/nostr_dvm/tasks/textextraction_whisperx.py +++ b/nostr_dvm/tasks/textextraction_whisperx.py @@ -29,7 +29,7 @@ class SpeechToTextWhisperX(DVMTaskInterface): admin_config: AdminConfig = None, options=None): super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/textgeneration_llmlite.py b/nostr_dvm/tasks/textgeneration_llmlite.py index e4d43ce..8c0d8a1 100644 --- a/nostr_dvm/tasks/textgeneration_llmlite.py +++ b/nostr_dvm/tasks/textgeneration_llmlite.py @@ -27,8 +27,7 @@ class TextGenerationLLMLite(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/texttospeech.py b/nostr_dvm/tasks/texttospeech.py index c5d1ceb..5cbee16 100644 --- a/nostr_dvm/tasks/texttospeech.py +++ b/nostr_dvm/tasks/texttospeech.py @@ -33,17 +33,23 @@ class TextToSpeech(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] input_type = tag.as_vec()[2] if input_type != "event" and input_type != "job" and input_type != "text": return False + if input_type == "text" and len(input_value) > 250: + return False + if input_type == "event": + evt = get_event_by_id(tag.as_vec()[1], client=client, config=dvm_config) + if len(evt.content()) > 250: + return False elif tag.as_vec()[0] == 'param': param = tag.as_vec()[1] if param == "language": # check for param type - if tag.as_vec()[2] != "en": # todo add other available languages + if tag.as_vec()[2] != "en": # todo add other available languages return False return True diff --git a/nostr_dvm/tasks/translation_google.py b/nostr_dvm/tasks/translation_google.py index b4ed1e3..ca04070 100644 --- a/nostr_dvm/tasks/translation_google.py +++ b/nostr_dvm/tasks/translation_google.py @@ -28,7 +28,7 @@ class TranslationGoogle(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/translation_libretranslate.py b/nostr_dvm/tasks/translation_libretranslate.py index cc6f6d2..dac2d5b 100644 --- a/nostr_dvm/tasks/translation_libretranslate.py +++ b/nostr_dvm/tasks/translation_libretranslate.py @@ -30,7 +30,7 @@ class TranslationLibre(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options, task) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/trending_notes_nostrband.py b/nostr_dvm/tasks/trending_notes_nostrband.py index 85c2e73..9465e92 100644 --- a/nostr_dvm/tasks/trending_notes_nostrband.py +++ b/nostr_dvm/tasks/trending_notes_nostrband.py @@ -28,7 +28,7 @@ class TrendingNotesNostrBand(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/tasks/videogeneration_replicate_svd.py b/nostr_dvm/tasks/videogeneration_replicate_svd.py index 91954c8..93cd3aa 100644 --- a/nostr_dvm/tasks/videogeneration_replicate_svd.py +++ b/nostr_dvm/tasks/videogeneration_replicate_svd.py @@ -34,7 +34,7 @@ class VideoGenerationReplicateSVD(DVMTaskInterface): dvm_config.SCRIPT = os.path.abspath(__file__) super().__init__(name, dvm_config, nip89config, admin_config, options) - def is_input_supported(self, tags): + def is_input_supported(self, tags, client=None, dvm_config=None): for tag in tags: if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] diff --git a/nostr_dvm/utils/backend_utils.py b/nostr_dvm/utils/backend_utils.py index 7bcfb28..cb69d59 100644 --- a/nostr_dvm/utils/backend_utils.py +++ b/nostr_dvm/utils/backend_utils.py @@ -140,7 +140,7 @@ def check_task_is_supported(event: Event, client, config=None): # See if current dvm can handle input for given task for dvm in dvm_config.SUPPORTED_DVMS: if dvm.TASK == task: - if not dvm.is_input_supported(event.tags()): + if not dvm.is_input_supported(event.tags(), client, config): return False, task return True, task