add client, config to input_supported

This commit is contained in:
Believethehype
2023-12-28 22:56:41 +01:00
parent 4c07beff7b
commit bc3701d498
21 changed files with 28 additions and 23 deletions

View File

@@ -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

View File

@@ -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]

View File

@@ -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]

View File

@@ -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

View File

@@ -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]

View File

@@ -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]

View File

@@ -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]

View File

@@ -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]

View File

@@ -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:

View File

@@ -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':

View File

@@ -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':

View File

@@ -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]

View File

@@ -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]

View File

@@ -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]

View File

@@ -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]

View File

@@ -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

View File

@@ -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]

View File

@@ -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]

View File

@@ -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]

View File

@@ -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]

View File

@@ -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