Browse Source

Merge pull request #13089 from izumi0004/fix/tool_calls

fix: handling tool calls in streamed responses
Tim Jaeryang Baek 3 months ago
parent
commit
7f85436a94
1 changed files with 9 additions and 0 deletions
  1. 9 0
      backend/open_webui/utils/middleware.py

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

@@ -1671,6 +1671,15 @@ async def process_chat_response(
 
                                                 if current_response_tool_call is None:
                                                     # Add the new tool call
+                                                    delta_tool_call.setdefault(
+                                                        "function", {}
+                                                    )
+                                                    delta_tool_call["function"].setdefault(
+                                                        "name", ""
+                                                    )
+                                                    delta_tool_call["function"].setdefault(
+                                                        "arguments", ""
+                                                    )
                                                     response_tool_calls.append(
                                                         delta_tool_call
                                                     )