Skip to content

Commit 7119c03

Browse files
authored
change the finish_reason of tool_calls
1 parent cf7178c commit 7119c03

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lightllm/server/api_openai.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ async def chat_completions_impl(request: ChatCompletionRequest, raw_request: Req
226226

227227
if tool_choice != "none" and any([i in text for i in TOOLS_TAG_LIST]):
228228
if finish_reason == "stop":
229-
finish_reason = "function_call"
229+
finish_reason = "tool_calls"
230230
try:
231231
# 为 tool_call_parser 提供默认值
232232
tool_parser = getattr(g_objs.args, "tool_call_parser", None) or "llama3"
@@ -249,6 +249,8 @@ async def chat_completions_impl(request: ChatCompletionRequest, raw_request: Req
249249
HTTPStatus.BAD_REQUEST,
250250
"Failed to parse fc related info to json format!",
251251
)
252+
if finish_reason == "tool_calls":
253+
text = ""
252254
chat_message = ChatMessage(role="assistant", content=text, tool_calls=tool_calls)
253255
choice = ChatCompletionResponseChoice(
254256
index=i,
@@ -348,7 +350,7 @@ async def stream_results() -> AsyncGenerator[bytes, None]:
348350
choice_data = ChatCompletionStreamResponseChoice(
349351
index=0,
350352
delta=DeltaMessage(role="assistant", tool_calls=[tool_call]),
351-
finish_reason="function_call",
353+
finish_reason="tool_calls",
352354
)
353355
chunk = ChatCompletionStreamResponse(
354356
id=group_request_id,

0 commit comments

Comments
 (0)