[Fix] Serve drops some attributes at serialization#46680
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Contributor
|
CI Dashboard: View test results in Grafana |
SunMarc
approved these changes
Jun 16, 2026
SunMarc
left a comment
Member
There was a problem hiding this comment.
Thanks, I've fixed this issue on this PR but still waiting for @Rocketknight1 PR to be merged. #46267
Still the solution here seems a bit more elegant than what i did so I will update my PR later on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue in
serve.In
chat_completion.py, we create a subclass ofChatCompletionMessagein whichreasoning_contentis a field. When this class is serialized, the field is lost because pydantic v2 uses the serializer from the annotated class (the originalChatCompletionMessagethat was subclassed) rather than the runtime class (the subclass that we instantiate). Since the parent class, and its serializer, don't know about this subclass's attribute, it is lost at serialisation.This PR fixes this by removing the subclass and rather passing
reasoning_contentas an extra field, which is allowed by the base class and serialized as well.This fixes 6 tests in
test_serve.pySince I am not familiar with pydantic, this may not be the best way to resolve this. On the off-chance it is, happy to help.