This commit is contained in:
Timothy Jaeryang Baek 2024-11-17 21:39:52 -08:00
parent b0a19d0dda
commit 0faa39ace9

View File

@ -1047,17 +1047,17 @@ async def get_all_models():
) )
# Process action_ids to get the actions # Process action_ids to get the actions
def get_action_items_from_module(module): def get_action_items_from_module(function, module):
actions = [] actions = []
if hasattr(module, "actions"): if hasattr(module, "actions"):
actions = module.actions actions = module.actions
return [ return [
{ {
"id": f"{module.id}.{action['id']}", "id": f"{function.id}.{action['id']}",
"name": action.get("name", f"{module.name} ({action['id']})"), "name": action.get("name", f"{function.name} ({action['id']})"),
"description": module.meta.description, "description": function.meta.description,
"icon_url": action.get( "icon_url": action.get(
"icon_url", module.meta.manifest.get("icon_url", None) "icon_url", function.meta.manifest.get("icon_url", None)
), ),
} }
for action in actions for action in actions
@ -1065,10 +1065,10 @@ async def get_all_models():
else: else:
return [ return [
{ {
"id": module.id, "id": function.id,
"name": module.name, "name": function.name,
"description": module.meta.description, "description": function.meta.description,
"icon_url": module.meta.manifest.get("icon_url", None), "icon_url": function.meta.manifest.get("icon_url", None),
} }
] ]
@ -1093,7 +1093,9 @@ async def get_all_models():
raise Exception(f"Action not found: {action_id}") raise Exception(f"Action not found: {action_id}")
function_module = get_function_module_by_id(action_id) function_module = get_function_module_by_id(action_id)
model["actions"].extend(get_action_items_from_module(function_module)) model["actions"].extend(
get_action_items_from_module(action_function, function_module)
)
return models return models