[responsesAPI] fix incomplete_messages for simple/parsable context (#31836)
Signed-off-by: Andrew Xia <axia@fb.com> Co-authored-by: Andrew Xia <axia@fb.com>
This commit is contained in:
@@ -692,6 +692,10 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# TODO: Calculate usage.
|
||||
# assert final_res.prompt_token_ids is not None
|
||||
num_tool_output_tokens = 0
|
||||
|
||||
# Check finish reason from the parser
|
||||
if context.parser.finish_reason == "length":
|
||||
status = "incomplete"
|
||||
else:
|
||||
assert isinstance(context, SimpleContext)
|
||||
# Use final_output which has accumulated text/token_ids/logprobs
|
||||
@@ -703,6 +707,10 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# finish_reason='error' indicates retryable internal error
|
||||
self._raise_if_error(final_output.finish_reason, request.request_id)
|
||||
|
||||
# Check if generation was stopped due to max_tokens
|
||||
if final_output.finish_reason == "length":
|
||||
status = "incomplete"
|
||||
|
||||
output = self._make_response_output_items(request, final_output, tokenizer)
|
||||
|
||||
if request.enable_response_messages:
|
||||
|
||||
Reference in New Issue
Block a user