mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-18 18:25:53 +08:00
refac
This commit is contained in:
parent
115f34069a
commit
af2c5f3a18
@ -1206,16 +1206,17 @@ async def process_chat_response(
|
|||||||
break
|
break
|
||||||
|
|
||||||
if tool_result:
|
if tool_result:
|
||||||
tool_calls_display_content = f'{tool_calls_display_content}\n<details type="tool_calls" done="true" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}" result="{html.escape(json.dumps(tool_result))}">\n<summary>Tool Executed</summary>\n</details>'
|
tool_calls_display_content = f'{tool_calls_display_content}\n<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))}">\n<summary>Tool Executed</summary>\n</details>'
|
||||||
else:
|
else:
|
||||||
tool_calls_display_content = f'{tool_calls_display_content}\n<details type="tool_calls" done="false" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}">\n<summary>Executing...</summary>\n</details>'
|
tool_calls_display_content = f'{tool_calls_display_content}\n<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>'
|
||||||
|
|
||||||
if not raw:
|
if not raw:
|
||||||
content = f"{content}\n{tool_calls_display_content}\n"
|
content = f"{content}\n{tool_calls_display_content}\n\n"
|
||||||
else:
|
else:
|
||||||
tool_calls_display_content = ""
|
tool_calls_display_content = ""
|
||||||
|
|
||||||
for tool_call in tool_calls:
|
for tool_call in tool_calls:
|
||||||
|
tool_call_id = tool_call.get("id", "")
|
||||||
tool_name = tool_call.get("function", {}).get(
|
tool_name = tool_call.get("function", {}).get(
|
||||||
"name", ""
|
"name", ""
|
||||||
)
|
)
|
||||||
@ -1223,10 +1224,10 @@ async def process_chat_response(
|
|||||||
"arguments", ""
|
"arguments", ""
|
||||||
)
|
)
|
||||||
|
|
||||||
tool_calls_display_content = f'{tool_calls_display_content}\n<details type="tool_calls" done="false" name="{tool_name}" arguments="{html.escape(json.dumps(tool_arguments))}">\n<summary>Executing...</summary>\n</details>'
|
tool_calls_display_content = f'{tool_calls_display_content}\n<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>'
|
||||||
|
|
||||||
if not raw:
|
if not raw:
|
||||||
content = f"{content}\n{tool_calls_display_content}\n"
|
content = f"{content}\n{tool_calls_display_content}\n\n"
|
||||||
|
|
||||||
elif block["type"] == "reasoning":
|
elif block["type"] == "reasoning":
|
||||||
reasoning_display_content = "\n".join(
|
reasoning_display_content = "\n".join(
|
||||||
|
@ -102,12 +102,14 @@
|
|||||||
{:else if attributes?.type === 'tool_calls'}
|
{:else if attributes?.type === 'tool_calls'}
|
||||||
{#if attributes?.done === 'true'}
|
{#if attributes?.done === 'true'}
|
||||||
<Markdown
|
<Markdown
|
||||||
|
id={`tool-calls-${attributes?.id}`}
|
||||||
content={$i18n.t('View Result from `{{NAME}}`', {
|
content={$i18n.t('View Result from `{{NAME}}`', {
|
||||||
NAME: attributes.name
|
NAME: attributes.name
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Markdown
|
<Markdown
|
||||||
|
id={`tool-calls-${attributes?.id}`}
|
||||||
content={$i18n.t('Executing `{{NAME}}`...', {
|
content={$i18n.t('Executing `{{NAME}}`...', {
|
||||||
NAME: attributes.name
|
NAME: attributes.name
|
||||||
})}
|
})}
|
||||||
@ -163,6 +165,7 @@
|
|||||||
{#if attributes?.type === 'tool_calls'}
|
{#if attributes?.type === 'tool_calls'}
|
||||||
{#if attributes?.done === 'true'}
|
{#if attributes?.done === 'true'}
|
||||||
<Markdown
|
<Markdown
|
||||||
|
id={`tool-calls-${attributes?.id}-result`}
|
||||||
content={`> \`\`\`json
|
content={`> \`\`\`json
|
||||||
> ${JSON.parse(decode(attributes?.arguments))}
|
> ${JSON.parse(decode(attributes?.arguments))}
|
||||||
> ${JSON.parse(decode(attributes?.result))}
|
> ${JSON.parse(decode(attributes?.result))}
|
||||||
@ -170,6 +173,7 @@
|
|||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Markdown
|
<Markdown
|
||||||
|
id={`tool-calls-${attributes?.id}-result`}
|
||||||
content={`> \`\`\`json
|
content={`> \`\`\`json
|
||||||
> ${JSON.parse(decode(attributes?.arguments))}
|
> ${JSON.parse(decode(attributes?.arguments))}
|
||||||
> \`\`\``}
|
> \`\`\``}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user