Skip to content

Commit bbfaafa

Browse files
committed
fix fc stream
1 parent 4311248 commit bbfaafa

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lightllm/server/api_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class DeltaMessage(BaseModel):
193193
class ChatCompletionStreamResponseChoice(BaseModel):
194194
index: int
195195
delta: DeltaMessage
196-
finish_reason: Optional[Literal["stop", "length"]] = None
196+
finish_reason: Optional[Literal["stop", "length", "tool_calls"]] = None
197197

198198

199199
class ChatCompletionStreamResponse(BaseModel):

lightllm/server/api_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ async def stream_results() -> AsyncGenerator[bytes, None]:
281281
if request.tool_choice != "none" and request.tools:
282282
delta = request_output
283283
group_request_id = convert_sub_id_to_group_id(sub_req_id)
284-
index = metadata["id"]
284+
index = sub_req_id
285285
finish_reason = finish_status.get_finish_reason()
286286

287287
if index not in parser_dict:

lightllm/server/function_call_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def parse_streaming_increment(self, new_text: str, tools: List[Tool]) -> Streami
307307
if cur_arguments:
308308
# Calculate how much of the arguments we've already streamed
309309
sent = len(self.streamed_args_for_tool[self.current_tool_id])
310-
cur_args_json = json.dumps(cur_arguments)
310+
cur_args_json = json.dumps(cur_arguments, ensure_ascii=False)
311311
prev_arguments = None
312312
if self.current_tool_id < len(self.prev_tool_call_arr):
313313
prev_arguments = self.prev_tool_call_arr[self.current_tool_id].get("arguments")
@@ -330,7 +330,7 @@ def parse_streaming_increment(self, new_text: str, tools: List[Tool]) -> Streami
330330

331331
# If the tool is still being parsed, send incremental changes
332332
elif prev_arguments:
333-
prev_args_json = json.dumps(prev_arguments)
333+
prev_args_json = json.dumps(prev_arguments, ensure_ascii=False)
334334
if cur_args_json != prev_args_json:
335335
prefix = _find_common_prefix(prev_args_json, cur_args_json)
336336
argument_diff = prefix[sent:]

0 commit comments

Comments
 (0)