Skip to content

Conversation

garybadwal
Copy link
Contributor

@garybadwal garybadwal commented Sep 27, 2025

Related Issues

Proposed Changes

Added a new CometAPIChatGenerator class that extends OpenAIChatGenerator to support the Comet API as a backend for chat generation.

  • Configures api_base_url to point to https://api.cometapi.com/v1.
  • Supports authentication via COMET_API_KEY environment variable (using Secret.from_env_var).
  • Allows configuration of model name, streaming callbacks, tools, retry logic, and HTTP client kwargs, same as OpenAIChatGenerator.
  • Default model is set to gpt-4o-mini.

This provides a seamless way to use CometAPI as a drop-in replacement for OpenAI within Haystack.

How did you test it?

  • Verified initialization of CometAPIChatGenerator with and without explicit parameters.
  • Tested that it correctly inherits all functionality from OpenAIChatGenerator.
  • Manually checked API base URL override (api_base_url = https://api.cometapi.com/v1).
  • Confirmed loading of API key from environment variable (COMET_API_KEY).

Notes for the reviewer

  • The main change is introducing the CometAPIChatGenerator class.
  • Implementation reuses all OpenAIChatGenerator logic, only customizing api_base_url and defaults.
  • Please review whether we should add integration tests with a real Comet API key (currently avoided to keep CI clean).

Checklist

garybadwal and others added 30 commits May 24, 2025 16:24
…der to use private attributes for initialization
@garybadwal
Copy link
Contributor Author

Hi @sjrl, could you take a look at the PR and check if it includes everything you requested?

Comment on lines 75 to 81
# TODO: remove lint environment once this integration is properly typed
# test environment should be used instead
# https://github.com/deepset-ai/haystack-core-integrations/issues/1771
[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243", "more-itertools"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you follow the pyproject.toml format used in the OpenRouter integration.

This TODO only exists in a few remaining integrations and we should avoid using one of those as an example.

@sjrl
Copy link
Contributor

sjrl commented Oct 10, 2025

@garybadwal could you also add a py.typed file into the generators folder. Here is an example for the OpenRouter integration https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/openrouter/src/haystack_integrations/components/generators

@garybadwal
Copy link
Contributor Author

@sjrl, I’ve added the files and made the changes. However, the tests are now failing—could it be due to the missing API key, or am I doing something wrong? Could you please check and let me know?

@garybadwal
Copy link
Contributor Author

@TensorNull, I’ve added these resources. Please let me know what all you’d like to include in the description, and I’ll update the README.md accordingly.

@garybadwal
Copy link
Contributor Author

Hi @sjrl and @TensorNull, I have added all the requested information and included the new test cases from the OpenRouter integration. All tests are now passing. Could you please review the PR and let me know if there’s anything you’d like me to change or add?

@garybadwal
Copy link
Contributor Author

Hi @sjrl, just checking if you or @TensorNull can give a review to the changes requested. So I can fix things if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:cometapi topic:CI type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add CometAPI as an LLM provider

5 participants