This commit is contained in:
Timothy Jaeryang Baek 2025-02-25 01:03:15 -08:00
parent 46c4da4864
commit b964b175d4

View File

@ -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(