瀏覽代碼

enh: tool args parse json fallback

Timothy Jaeryang Baek 1 月之前
父節點
當前提交
b5909ffe97
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      backend/open_webui/utils/middleware.py

+ 9 - 0
backend/open_webui/utils/middleware.py

@@ -1846,6 +1846,15 @@ async def process_chat_response(
                             )
                         except Exception as e:
                             log.debug(e)
+                            # Fallback to JSON parsing
+                            try:
+                                tool_function_params = json.loads(
+                                    tool_call.get("function", {}).get("arguments", "{}")
+                                )
+                            except Exception as e:
+                                log.debug(
+                                    f"Error parsing tool call arguments: {tool_call.get('function', {}).get('arguments', '{}')}"
+                                )
 
                         tool_result = None