mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-20 01:29:05 +08:00
refac
This commit is contained in:
parent
46c4da4864
commit
b964b175d4
@ -1474,6 +1474,7 @@ async def process_chat_response(
|
|||||||
extra_params=extra_params,
|
extra_params=extra_params,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if data:
|
||||||
if "selected_model_id" in data:
|
if "selected_model_id" in data:
|
||||||
model_id = data["selected_model_id"]
|
model_id = data["selected_model_id"]
|
||||||
Chats.upsert_message_to_chat_by_id_and_message_id(
|
Chats.upsert_message_to_chat_by_id_and_message_id(
|
||||||
@ -1493,7 +1494,9 @@ async def process_chat_response(
|
|||||||
|
|
||||||
if delta_tool_calls:
|
if delta_tool_calls:
|
||||||
for delta_tool_call in delta_tool_calls:
|
for delta_tool_call in delta_tool_calls:
|
||||||
tool_call_index = delta_tool_call.get("index")
|
tool_call_index = delta_tool_call.get(
|
||||||
|
"index"
|
||||||
|
)
|
||||||
|
|
||||||
if tool_call_index is not None:
|
if tool_call_index is not None:
|
||||||
if (
|
if (
|
||||||
@ -1507,14 +1510,18 @@ async def process_chat_response(
|
|||||||
delta_name = delta_tool_call.get(
|
delta_name = delta_tool_call.get(
|
||||||
"function", {}
|
"function", {}
|
||||||
).get("name")
|
).get("name")
|
||||||
delta_arguments = delta_tool_call.get(
|
delta_arguments = (
|
||||||
|
delta_tool_call.get(
|
||||||
"function", {}
|
"function", {}
|
||||||
).get("arguments")
|
).get("arguments")
|
||||||
|
)
|
||||||
|
|
||||||
if delta_name:
|
if delta_name:
|
||||||
response_tool_calls[
|
response_tool_calls[
|
||||||
tool_call_index
|
tool_call_index
|
||||||
]["function"]["name"] += delta_name
|
]["function"][
|
||||||
|
"name"
|
||||||
|
] += delta_name
|
||||||
|
|
||||||
if delta_arguments:
|
if delta_arguments:
|
||||||
response_tool_calls[
|
response_tool_calls[
|
||||||
@ -2000,6 +2007,8 @@ async def process_chat_response(
|
|||||||
form_data=event,
|
form_data=event,
|
||||||
extra_params=extra_params,
|
extra_params=extra_params,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if event:
|
||||||
yield wrap_item(json.dumps(event))
|
yield wrap_item(json.dumps(event))
|
||||||
|
|
||||||
async for data in original_generator:
|
async for data in original_generator:
|
||||||
@ -2010,6 +2019,8 @@ async def process_chat_response(
|
|||||||
form_data=data,
|
form_data=data,
|
||||||
extra_params=extra_params,
|
extra_params=extra_params,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if data:
|
||||||
yield data
|
yield data
|
||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user