mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac: tool message format
This commit is contained in:
parent
e5829572ff
commit
37bf0087e5
1 changed files with 3 additions and 3 deletions
|
|
@ -1501,7 +1501,7 @@ async def process_chat_response(
|
||||||
tool_result_files = result.get("files", None)
|
tool_result_files = result.get("files", None)
|
||||||
break
|
break
|
||||||
|
|
||||||
if tool_result:
|
if tool_result is not None:
|
||||||
tool_calls_display_content = f'{tool_calls_display_content}<details type="tool_calls" done="true" id="{tool_call_id}" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}" result="{html.escape(json.dumps(tool_result, ensure_ascii=False))}" files="{html.escape(json.dumps(tool_result_files)) if tool_result_files else ""}">\n<summary>Tool Executed</summary>\n</details>\n'
|
tool_calls_display_content = f'{tool_calls_display_content}<details type="tool_calls" done="true" id="{tool_call_id}" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}" result="{html.escape(json.dumps(tool_result, ensure_ascii=False))}" files="{html.escape(json.dumps(tool_result_files)) if tool_result_files else ""}">\n<summary>Tool Executed</summary>\n</details>\n'
|
||||||
else:
|
else:
|
||||||
tool_calls_display_content = f'{tool_calls_display_content}<details type="tool_calls" done="false" id="{tool_call_id}" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}">\n<summary>Executing...</summary>\n</details>\n'
|
tool_calls_display_content = f'{tool_calls_display_content}<details type="tool_calls" done="false" id="{tool_call_id}" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}">\n<summary>Executing...</summary>\n</details>\n'
|
||||||
|
|
@ -1616,7 +1616,7 @@ async def process_chat_response(
|
||||||
{
|
{
|
||||||
"role": "tool",
|
"role": "tool",
|
||||||
"tool_call_id": result["tool_call_id"],
|
"tool_call_id": result["tool_call_id"],
|
||||||
"content": result["content"],
|
"content": result.get("content", "") or "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
temp_blocks = []
|
temp_blocks = []
|
||||||
|
|
@ -2341,7 +2341,7 @@ async def process_chat_response(
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
"tool_call_id": tool_call_id,
|
"tool_call_id": tool_call_id,
|
||||||
"content": tool_result,
|
"content": tool_result or "",
|
||||||
**(
|
**(
|
||||||
{"files": tool_result_files}
|
{"files": tool_result_files}
|
||||||
if tool_result_files
|
if tool_result_files
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue