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