mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[BugFix] fix max streaming tokens invalid (#3799)
* Update serving_chat.py * Update serving_completion.py * Update serving_completion.py
This commit is contained in:
@@ -182,7 +182,7 @@ class OpenAIServingChat:
|
|||||||
if request.max_streaming_response_tokens is not None
|
if request.max_streaming_response_tokens is not None
|
||||||
else (request.metadata or {}).get("max_streaming_response_tokens", 1)
|
else (request.metadata or {}).get("max_streaming_response_tokens", 1)
|
||||||
) # dierctly passed & passed in metadata
|
) # dierctly passed & passed in metadata
|
||||||
|
max_streaming_response_tokens = max(max_streaming_response_tokens, 1)
|
||||||
enable_thinking = request.chat_template_kwargs.get("enable_thinking") if request.chat_template_kwargs else None
|
enable_thinking = request.chat_template_kwargs.get("enable_thinking") if request.chat_template_kwargs else None
|
||||||
if enable_thinking is None:
|
if enable_thinking is None:
|
||||||
enable_thinking = request.metadata.get("enable_thinking") if request.metadata else None
|
enable_thinking = request.metadata.get("enable_thinking") if request.metadata else None
|
||||||
@@ -370,11 +370,6 @@ class OpenAIServingChat:
|
|||||||
api_server_logger.info(f"Chat Streaming response last send: {chunk.model_dump_json()}")
|
api_server_logger.info(f"Chat Streaming response last send: {chunk.model_dump_json()}")
|
||||||
choices = []
|
choices = []
|
||||||
|
|
||||||
if choices:
|
|
||||||
chunk.choices = choices
|
|
||||||
yield f"data: {chunk.model_dump_json(exclude_unset=True)}\n\n"
|
|
||||||
choices = []
|
|
||||||
|
|
||||||
if include_usage:
|
if include_usage:
|
||||||
completion_tokens = previous_num_tokens
|
completion_tokens = previous_num_tokens
|
||||||
usage = UsageInfo(
|
usage = UsageInfo(
|
||||||
|
@@ -331,6 +331,7 @@ class OpenAIServingCompletion:
|
|||||||
if request.max_streaming_response_tokens is not None
|
if request.max_streaming_response_tokens is not None
|
||||||
else (request.suffix or {}).get("max_streaming_response_tokens", 1)
|
else (request.suffix or {}).get("max_streaming_response_tokens", 1)
|
||||||
) # dierctly passed & passed in suffix
|
) # dierctly passed & passed in suffix
|
||||||
|
max_streaming_response_tokens = max(max_streaming_response_tokens, 1)
|
||||||
choices = []
|
choices = []
|
||||||
chunk = CompletionStreamResponse(
|
chunk = CompletionStreamResponse(
|
||||||
id=request_id,
|
id=request_id,
|
||||||
@@ -461,10 +462,6 @@ class OpenAIServingCompletion:
|
|||||||
)
|
)
|
||||||
yield f"data: {usage_chunk.model_dump_json(exclude_unset=True)}\n\n"
|
yield f"data: {usage_chunk.model_dump_json(exclude_unset=True)}\n\n"
|
||||||
api_server_logger.info(f"Completion Streaming response last send: {chunk.model_dump_json()}")
|
api_server_logger.info(f"Completion Streaming response last send: {chunk.model_dump_json()}")
|
||||||
if choices:
|
|
||||||
chunk.choices = choices
|
|
||||||
yield f"data: {chunk.model_dump_json(exclude_unset=True)}\n\n"
|
|
||||||
choices = []
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_server_logger.error(f"Error in completion_stream_generator: {e}, {str(traceback.format_exc())}")
|
api_server_logger.error(f"Error in completion_stream_generator: {e}, {str(traceback.format_exc())}")
|
||||||
|
Reference in New Issue
Block a user