Timothy Jaeryang Baek 2 months ago
parent
commit
56dc7c5640
2 changed files with 13 additions and 8 deletions
  1. 2 1
      backend/open_webui/utils/middleware.py
  2. 11 7
      backend/open_webui/utils/tools.py

+ 2 - 1
backend/open_webui/utils/middleware.py

@@ -1912,7 +1912,8 @@ async def process_chat_response(
                         tool_result_files = []
                         tool_result_files = []
                         if isinstance(tool_result, list):
                         if isinstance(tool_result, list):
                             for item in tool_result:
                             for item in tool_result:
-                                if item.startswith("data:"):
+                                # check if string
+                                if isinstance(item, str) and item.startswith("data:"):
                                     tool_result_files.append(item)
                                     tool_result_files.append(item)
                                     tool_result.remove(item)
                                     tool_result.remove(item)
 
 

+ 11 - 7
backend/open_webui/utils/tools.py

@@ -69,14 +69,18 @@ def get_tools(
                     elif auth_type == "session":
                     elif auth_type == "session":
                         token = request.state.token.credentials
                         token = request.state.token.credentials
 
 
+                    async def tool_function(**args):
+                        return await execute_tool_server(
+                            token=token,
+                            url=tool_server_data["url"],
+                            name=function_name,
+                            params=args,
+                            server_data=tool_server_data,
+                        )
+
                     callable = get_async_tool_function_and_apply_extra_params(
                     callable = get_async_tool_function_and_apply_extra_params(
-                        execute_tool_server,
-                        {
-                            "token": token,
-                            "url": tool_server_data["url"],
-                            "name": function_name,
-                            "server_data": tool_server_data,
-                        },
+                        tool_function,
+                        {},
                     )
                     )
 
 
                     tool_dict = {
                     tool_dict = {