Skip to content

Made content in ChatCompletionResponseMessage an optional field.#25

Merged
mosalov merged 3 commits intomainfrom
krai-less-strict-validation-for-openai-response
Dec 5, 2025
Merged

Made content in ChatCompletionResponseMessage an optional field.#25
mosalov merged 3 commits intomainfrom
krai-less-strict-validation-for-openai-response

Conversation

@mosalov
Copy link
Copy Markdown
Collaborator

@mosalov mosalov commented Nov 13, 2025

What does this PR do?

This PR makes the field content in ChatCompletionResponseMessage optional, to make it compatible with the model gpt-oss-120b. See the linked issue for details: #24 .

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor/cleanup

Related issues

Closes #24

Testing

  • Tests added/updated
  • All tests pass locally
  • Manual testing completed

Checklist

  • Code follows project style
  • Pre-commit hooks pass
  • Documentation updated (if needed)

@mosalov mosalov requested a review from a team as a code owner November 13, 2025 11:04
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 13, 2025

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @mosalov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a compatibility issue with the gpt-oss-120b model by modifying the ChatCompletionResponseMessage schema. The content field, which previously was mandatory, has now been made optional. This adjustment ensures that the system can gracefully handle responses from models that may not always provide content, thereby preventing errors and improving the robustness of the inference endpoint.

Highlights

  • ChatCompletionResponseMessage Schema Update: The content field within the ChatCompletionResponseMessage class has been updated to be optional, allowing for scenarios where this field might not be present.
  • gpt-oss-120b Model Compatibility: This change specifically addresses a compatibility issue with the gpt-oss-120b model, ensuring that responses from this model are correctly parsed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly makes the content field in ChatCompletionResponseMessage optional to support the gpt-oss-120b model. While the change in src/inference_endpoint/openai/openai_types_gen.py is correct, it may introduce a runtime error in src/inference_endpoint/openai/openai_adapter.py where this field is consumed. I've added a specific comment on the change with details about this potential issue and a suggested fix.

Comment thread src/inference_endpoint/openai/openai_types_gen.py Outdated
@viraatc viraatc self-requested a review November 13, 2025 23:26
@arekay-nv
Copy link
Copy Markdown
Collaborator

@mosalov Can you move the changes to the openai_adapter.py where we have some other fixes as well. We can collect the fixes there until we have a better way to address the incompatibilities.

@mosalov
Copy link
Copy Markdown
Collaborator Author

mosalov commented Dec 5, 2025

@arekay-nv sorry, missed the message. I have moved the logic.

@mosalov mosalov force-pushed the krai-less-strict-validation-for-openai-response branch from 938ed5d to 9dc08c1 Compare December 5, 2025 13:50
Copy link
Copy Markdown
Collaborator

@arekay-nv arekay-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

@mosalov mosalov merged commit f1f1662 into main Dec 5, 2025
4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 5, 2025
@arekay-nv arekay-nv deleted the krai-less-strict-validation-for-openai-response branch April 2, 2026 03:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: Benchmarking gpt-oss-120b crashes because of a too strict data type validation

3 participants