mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac: tag handling
This commit is contained in:
parent
e9fb161bcd
commit
2e36540023
2 changed files with 18 additions and 5 deletions
|
|
@ -776,10 +776,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||||
if folder and folder.data:
|
if folder and folder.data:
|
||||||
if "system_prompt" in folder.data:
|
if "system_prompt" in folder.data:
|
||||||
form_data = apply_model_system_prompt_to_body(
|
form_data = apply_model_system_prompt_to_body(
|
||||||
folder.data["system_prompt"],
|
folder.data["system_prompt"], form_data, metadata, user
|
||||||
form_data,
|
|
||||||
metadata,
|
|
||||||
user
|
|
||||||
)
|
)
|
||||||
if "files" in folder.data:
|
if "files" in folder.data:
|
||||||
form_data["files"] = [
|
form_data["files"] = [
|
||||||
|
|
@ -2079,6 +2076,19 @@ async def process_chat_response(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
content_blocks[-1]["type"] == "reasoning"
|
||||||
|
and content_blocks[-1].get("attributes", {}).get("type")
|
||||||
|
== "reasoning_content"
|
||||||
|
):
|
||||||
|
reasoning_block = content_blocks[-1]
|
||||||
|
if reasoning_block.get("ended_at") is None:
|
||||||
|
reasoning_block["ended_at"] = time.time()
|
||||||
|
reasoning_block["duration"] = int(
|
||||||
|
reasoning_block["ended_at"]
|
||||||
|
- reasoning_block["started_at"]
|
||||||
|
)
|
||||||
|
|
||||||
if response_tool_calls:
|
if response_tool_calls:
|
||||||
tool_calls.append(response_tool_calls)
|
tool_calls.append(response_tool_calls)
|
||||||
|
|
||||||
|
|
@ -2091,6 +2101,7 @@ async def process_chat_response(
|
||||||
tool_call_retries = 0
|
tool_call_retries = 0
|
||||||
|
|
||||||
while len(tool_calls) > 0 and tool_call_retries < MAX_TOOL_CALL_RETRIES:
|
while len(tool_calls) > 0 and tool_call_retries < MAX_TOOL_CALL_RETRIES:
|
||||||
|
|
||||||
tool_call_retries += 1
|
tool_call_retries += 1
|
||||||
|
|
||||||
response_tool_calls = tool_calls.pop(0)
|
response_tool_calls = tool_calls.pop(0)
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,9 @@
|
||||||
<div class="">
|
<div class="">
|
||||||
{#if attributes?.type === 'reasoning'}
|
{#if attributes?.type === 'reasoning'}
|
||||||
{#if attributes?.done === 'true' && attributes?.duration}
|
{#if attributes?.done === 'true' && attributes?.duration}
|
||||||
{#if attributes.duration < 60}
|
{#if attributes.duration < 1}
|
||||||
|
{$i18n.t('Thought for less than a second')}
|
||||||
|
{:else if attributes.duration < 60}
|
||||||
{$i18n.t('Thought for {{DURATION}} seconds', {
|
{$i18n.t('Thought for {{DURATION}} seconds', {
|
||||||
DURATION: attributes.duration
|
DURATION: attributes.duration
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue