Skip to content

fix(cometapi): make CometAPIChatGenerator deserializable in pipelines#3542

Merged
julian-risch merged 1 commit into
mainfrom
fix/cometapi-pipeline-deserialization
Jul 3, 2026
Merged

fix(cometapi): make CometAPIChatGenerator deserializable in pipelines#3542
julian-risch merged 1 commit into
mainfrom
fix/cometapi-pipeline-deserialization

Conversation

@julian-risch

@julian-risch julian-risch commented Jul 3, 2026

Copy link
Copy Markdown
Member

Related Issues

  • None (found while working on test: make Tool/Agent serialization assertions version-agnostic for Haystack 2.x/3.x #3533)
  • CometAPIChatGenerator could not be deserialized as part of a pipeline: Pipeline.from_dict / Pipeline.loads failed for any pipeline containing it. Two bugs, both fixed here:
  • The class was never registered with the @component decorator.
  • The to_dict inherited from OpenAIChatGenerator serialized init parameters that CometAPIChatGenerator.__init__ does not accept (api_base_url, organization), so even a registered component failed to deserialize with TypeError: __init__() got an unexpected keyword argument 'api_base_url'.

Proposed Changes:

  • Added the decorator (and the two-argument super(CometAPIChatGenerator, self).__init__ form it requires, since the decorator recreates the class — same pattern as OpenRouterChatGenerator).
    Added a to_dict override 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

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added integration:cometapi type:documentation Improvements or additions to documentation labels Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Coverage report (cometapi)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/cometapi/src/haystack_integrations/components/generators/cometapi/chat
  chat_generator.py
Project Total  

This report was generated by python-coverage-comment-action

@julian-risch julian-risch marked this pull request as ready for review July 3, 2026 07:30
@julian-risch julian-risch requested a review from a team as a code owner July 3, 2026 07:30
@julian-risch julian-risch requested review from sjrl and removed request for a team July 3, 2026 07:30
@julian-risch julian-risch enabled auto-merge (squash) July 3, 2026 07:30

@sjrl sjrl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@julian-risch julian-risch merged commit 6fea342 into main Jul 3, 2026
16 checks passed
@julian-risch julian-risch deleted the fix/cometapi-pipeline-deserialization branch July 3, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:cometapi type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants