Browse Source

refac: tool calling

Timothy Jaeryang Baek 2 tháng trước cách đây
mục cha
commit
cce1762cb8
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      backend/open_webui/utils/middleware.py

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

@@ -1156,8 +1156,13 @@ async def process_chat_response(
                             if not raw:
                                 content = f'{content}\n<details type="tool_calls" done="true" content="{html.escape(json.dumps(block_content))}" results="{html.escape(json.dumps(results))}">\n<summary>Tool Executed</summary>\n{result_display_content}\n</details>\n'
                         else:
+                            tool_calls_display_content = ""
+
+                            for tool_call in block_content:
+                                tool_calls_display_content = f"{tool_calls_display_content}\n> Executing {tool_call.get('function', {}).get('name', '')}"
+
                             if not raw:
-                                content = f'{content}\n<details type="tool_calls" done="false" content="{html.escape(json.dumps(block_content))}">\n<summary>Tool Executing...</summary>\n</details>\n'
+                                content = f'{content}\n<details type="tool_calls" done="false" content="{html.escape(json.dumps(block_content))}">\n<summary>Tool Executing...</summary>\n{tool_calls_display_content}\n</details>\n'
 
                     elif block["type"] == "reasoning":
                         reasoning_display_content = "\n".join(