From 0c1fab09ff90778ba8896fa314cd6d05ff9787a6 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 5 Sep 2024 18:55:31 +0200 Subject: [PATCH] refac --- backend/open_webui/apps/webui/main.py | 34 ++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/backend/open_webui/apps/webui/main.py b/backend/open_webui/apps/webui/main.py index 074b3144c..45fe3cad9 100644 --- a/backend/open_webui/apps/webui/main.py +++ b/backend/open_webui/apps/webui/main.py @@ -152,29 +152,33 @@ async def get_pipe_models(): # Check if function is a manifold if hasattr(function_module, "pipes"): - manifold_pipes = [] + sub_pipes = [] # Check if pipes is a function or a list - if callable(function_module.pipes): - manifold_pipes = function_module.pipes() - else: - manifold_pipes = function_module.pipes - for p in manifold_pipes: - manifold_pipe_id = f'{pipe.id}.{p["id"]}' - manifold_pipe_name = p["name"] + try: + if callable(function_module.pipes): + sub_pipes = function_module.pipes() + else: + sub_pipes = function_module.pipes + except Exception as e: + log.exception(e) + sub_pipes = [] + + print(sub_pipes) + + for p in sub_pipes: + sub_pipe_id = f'{pipe.id}.{p["id"]}' + sub_pipe_name = p["name"] if hasattr(function_module, "name"): - manifold_pipe_name = f"{function_module.name}{manifold_pipe_name}" + sub_pipe_name = f"{function_module.name}{sub_pipe_name}" pipe_flag = {"type": pipe.type} - if hasattr(function_module, "ChatValves"): - pipe_flag["valves_spec"] = function_module.ChatValves.schema() - pipe_models.append( { - "id": manifold_pipe_id, - "name": manifold_pipe_name, + "id": sub_pipe_id, + "name": sub_pipe_name, "object": "model", "created": pipe.created_at, "owned_by": "openai", @@ -183,8 +187,6 @@ async def get_pipe_models(): ) else: pipe_flag = {"type": "pipe"} - if hasattr(function_module, "ChatValves"): - pipe_flag["valves_spec"] = function_module.ChatValves.schema() pipe_models.append( {