refac: "tool_calls" finish reason support
This commit is contained in:
@@ -447,7 +447,7 @@ def openai_chat_completion_message_template(
|
|||||||
**({"tool_calls": tool_calls} if tool_calls else {}),
|
**({"tool_calls": tool_calls} if tool_calls else {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
template["choices"][0]["finish_reason"] = "stop"
|
template["choices"][0]["finish_reason"] = "tool_calls" if tool_calls else "stop"
|
||||||
|
|
||||||
if usage:
|
if usage:
|
||||||
template["usage"] = usage
|
template["usage"] = usage
|
||||||
|
|||||||
@@ -166,6 +166,9 @@ async def convert_streaming_response_ollama_to_openai(ollama_streaming_response)
|
|||||||
model, message_content, reasoning_content, openai_tool_calls, usage
|
model, message_content, reasoning_content, openai_tool_calls, usage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if done and openai_tool_calls:
|
||||||
|
data["choices"][0]["finish_reason"] = "tool_calls"
|
||||||
|
|
||||||
line = f"data: {json.dumps(data)}\n\n"
|
line = f"data: {json.dumps(data)}\n\n"
|
||||||
yield line
|
yield line
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user