mirror of
https://github.com/aljazceru/nostrdvm.git
synced 2025-12-22 08:24:25 +01:00
update to sdk 0.36 (for testing..)
This commit is contained in:
@@ -13,13 +13,13 @@ from nostr_dvm.utils.nostr_utils import get_event_by_id, get_referenced_event_by
|
||||
async def get_task(event, client, dvm_config):
|
||||
try:
|
||||
if event.kind() == EventDefinitions.KIND_NIP90_GENERIC: # use this for events that have no id yet, inclufr j tag
|
||||
for tag in event.tags():
|
||||
for tag in event.tags().to_vec():
|
||||
if tag.as_vec()[0] == 'j':
|
||||
return tag.as_vec()[1]
|
||||
else:
|
||||
return "unknown job: " + event.as_json()
|
||||
elif event.kind() == EventDefinitions.KIND_DM: # dm
|
||||
for tag in event.tags():
|
||||
for tag in event.tags().to_vec():
|
||||
if tag.as_vec()[0] == 'j':
|
||||
return tag.as_vec()[1]
|
||||
else:
|
||||
@@ -27,7 +27,7 @@ async def get_task(event, client, dvm_config):
|
||||
|
||||
# This looks a bit more complicated, but we do several tasks for text-extraction in the future
|
||||
elif event.kind() == EventDefinitions.KIND_NIP90_EXTRACT_TEXT:
|
||||
for tag in event.tags():
|
||||
for tag in event.tags().to_vec():
|
||||
if tag.as_vec()[0] == "i":
|
||||
if tag.as_vec()[2] == "url":
|
||||
file_type = check_url_is_readable(tag.as_vec()[1])
|
||||
@@ -44,7 +44,7 @@ async def get_task(event, client, dvm_config):
|
||||
evt = await get_event_by_id(tag.as_vec()[1], client=client, config=dvm_config)
|
||||
if evt is not None:
|
||||
if evt.kind() == 1063:
|
||||
for tg in evt.tags():
|
||||
for tg in evt.tags().to_vec():
|
||||
if tg.as_vec()[0] == 'url':
|
||||
file_type = check_url_is_readable(tg.as_vec()[1])
|
||||
if file_type == "pdf":
|
||||
@@ -60,7 +60,7 @@ async def get_task(event, client, dvm_config):
|
||||
elif event.kind() == EventDefinitions.KIND_NIP90_GENERATE_IMAGE:
|
||||
has_image_tag = False
|
||||
has_text_tag = False
|
||||
for tag in event.tags():
|
||||
for tag in event.tags().to_vec():
|
||||
if tag.as_vec()[0] == "i":
|
||||
if tag.as_vec()[2] == "url":
|
||||
file_type = check_url_is_readable(tag.as_vec()[1])
|
||||
@@ -130,7 +130,7 @@ async def check_task_is_supported(event: Event, client, config=None):
|
||||
try:
|
||||
dvm_config = config
|
||||
# Check for generic issues, event maformed, referenced event not found etc..
|
||||
if not is_input_supported_generic(event.tags(), client, dvm_config):
|
||||
if not is_input_supported_generic(event.tags().to_vec(), client, dvm_config):
|
||||
return False, ""
|
||||
|
||||
# See if current dvm supports the task
|
||||
@@ -140,7 +140,7 @@ async 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 await dvm.is_input_supported(event.tags(), client, config):
|
||||
if not await dvm.is_input_supported(event.tags().to_vec(), client, config):
|
||||
return False, task
|
||||
return True, task
|
||||
|
||||
|
||||
Reference in New Issue
Block a user