fix(cometapi): make CometAPIChatGenerator deserializable in pipelines#3542
Merged
Conversation
The class was never registered with @component, so Pipeline.from_dict could not resolve it, and the inherited to_dict serialized init parameters (api_base_url, organization) that CometAPIChatGenerator.__init__ does not accept. The serde-in-pipeline test never caught this because it compared the original generator to itself instead of deserializing; it now does a real dumps/loads round-trip like its sibling integrations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Coverage report (cometapi)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Related Issues
CometAPIChatGeneratorcould not be deserialized as part of a pipeline:Pipeline.from_dict/Pipeline.loadsfailed for any pipeline containing it. Two bugs, both fixed here:@componentdecorator.to_dictinherited fromOpenAIChatGeneratorserialized init parameters thatCometAPIChatGenerator.__init__does not accept (api_base_url,organization), so even a registered component failed to deserialize withTypeError: __init__() got an unexpected keyword argument 'api_base_url'.Proposed Changes:
super(CometAPIChatGenerator, self).__init__form it requires, since the decorator recreates the class — same pattern asOpenRouterChatGenerator).Added a
to_dictoverride that serializes exactly the component's own init parameters, mirroring openrouter.How did you test it?
The test now does a real
pipeline.dumps()/Pipeline.loads()round-trip and asserts the loaded pipeline equals the original.Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.🤖 Generated with Claude Code