-
Notifications
You must be signed in to change notification settings - Fork 254
Mkulakow/legacy pipeline finish reason #4169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
de09543
25a10fe
84a2622
95abd07
439f99f
7940fff
f97fd66
17f419d
f4f19a2
2d9d481
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -652,17 +652,30 @@ std::string OpenAIResponsesHandler::serializeUnaryResponse(ov::genai::EncodedRes | |
| OVMS_PROFILE_FUNCTION(); | ||
| usage.promptTokens = results.perf_metrics.get_num_input_tokens(); | ||
| usage.completionTokens = results.perf_metrics.get_num_generated_tokens(); | ||
| if (results.finish_reasons.empty()) { | ||
| SPDLOG_LOGGER_DEBUG(llm_calculator_logger, "Missing finish reason in unary LM responses generation result, defaulting to STOP"); | ||
| } | ||
| std::vector<ParsedOutput> parsedOutputs; | ||
| ov::genai::GenerationFinishReason responsesFinishReason = ov::genai::GenerationFinishReason::STOP; | ||
| for (const auto& tokens : results.tokens) { | ||
| parsedOutputs.push_back(parseOutputIfNeeded(tokens)); | ||
| } | ||
| return serializeUnaryResponseImpl(parsedOutputs); | ||
| for (const auto& finishReason : results.finish_reasons) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we have different implementation than chat/completions? cant we just take [0]? I think we also have batch size=1 here always
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now we could have same implementation for both APIs, but this approach highlights differences (for chat/completions there is one finish reason per output, for response one incomplete details for whole response) |
||
| if (finishReason == ov::genai::GenerationFinishReason::LENGTH) { | ||
| responsesFinishReason = ov::genai::GenerationFinishReason::LENGTH; | ||
| break; | ||
| } | ||
|
michalkulakowski marked this conversation as resolved.
|
||
| } | ||
| return serializeUnaryResponseImpl(parsedOutputs, responsesFinishReason); | ||
| } | ||
|
|
||
| std::string OpenAIResponsesHandler::serializeUnaryResponse(ov::genai::VLMDecodedResults& results, const std::string& textResponse) { | ||
| OVMS_PROFILE_FUNCTION(); | ||
| usage.promptTokens = results.perf_metrics.get_num_input_tokens(); | ||
| usage.completionTokens = results.perf_metrics.get_num_generated_tokens(); | ||
| if (results.finish_reasons.empty()) { | ||
| SPDLOG_LOGGER_DEBUG(llm_calculator_logger, "Missing finish reason in unary VLM responses generation result, defaulting to STOP"); | ||
| } | ||
| // Usage is already correctly set from perf_metrics above — no need for updateUsage. | ||
| std::vector<ParsedOutput> parsedOutputs; | ||
| if (!textResponse.empty()) { | ||
|
|
@@ -677,7 +690,14 @@ std::string OpenAIResponsesHandler::serializeUnaryResponse(ov::genai::VLMDecoded | |
| parsedOutputs.push_back(std::move(output)); | ||
| } | ||
| } | ||
| return serializeUnaryResponseImpl(parsedOutputs); | ||
| ov::genai::GenerationFinishReason responsesFinishReason = ov::genai::GenerationFinishReason::STOP; | ||
| for (const auto& finishReason : results.finish_reasons) { | ||
| if (finishReason == ov::genai::GenerationFinishReason::LENGTH) { | ||
| responsesFinishReason = ov::genai::GenerationFinishReason::LENGTH; | ||
| break; | ||
| } | ||
| } | ||
| return serializeUnaryResponseImpl(parsedOutputs, responsesFinishReason); | ||
| } | ||
|
|
||
| // --- Streaming event building blocks --- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.