@@ -5,33 +5,58 @@ description: "Comet API integration for Haystack"
55slug : " /integrations-cometapi"
66---
77
8- <a id =" haystack_integrations.components.generators.cometapi.chat.chat_generator " ></a >
98
10- ## Module haystack\_ integrations.components.generators.cometapi.chat.chat\_ generator
11-
12- <a id =" haystack_integrations.components.generators.cometapi.chat.chat_generator.CometAPIChatGenerator " ></a >
9+ ## haystack_integrations.components.generators.cometapi.chat.chat_generator
1310
1411### CometAPIChatGenerator
1512
13+ Bases: <code >OpenAIChatGenerator</code >
14+
1615A chat generator that uses the CometAPI for generating chat responses.
1716
1817This class extends Haystack's OpenAIChatGenerator to specifically interact with the CometAPI.
1918It sets the ` api_base_url ` to the CometAPI endpoint and allows for all the
2019standard configurations available in the OpenAIChatGenerator.
2120
22- ** Arguments** :
23-
24- - ` api_key ` : The API key for authenticating with the CometAPI. Defaults to
25- loading from the "COMET_API_KEY" environment variable.
26- - ` model ` : The name of the model to use for chat generation (e.g., "gpt-5-mini", "grok-3-mini").
27- Defaults to "gpt-5-mini".
28- - ` streaming_callback ` : An optional callable that will be called with each chunk of
29- a streaming response.
30- - ` generation_kwargs ` : Optional keyword arguments to pass to the underlying generation
31- API call.
32- - ` timeout ` : The maximum time in seconds to wait for a response from the API.
33- - ` max_retries ` : The maximum number of times to retry a failed API request.
34- - ` tools ` : An optional list of tool definitions that the model can use.
35- - ` tools_strict ` : If True, the model is forced to use one of the provided tools if a tool call is made.
36- - ` http_client_kwargs ` : Optional keyword arguments to pass to the HTTP client.
21+ #### __ init__
22+
23+ ``` python
24+ __init__ (
25+ * ,
26+ api_key: Secret = Secret.from_env_var(" COMET_API_KEY" ),
27+ model: str = " gpt-5-mini" ,
28+ streaming_callback: StreamingCallbackT | None = None ,
29+ generation_kwargs: dict[str , Any] | None = None ,
30+ timeout: int | None = None ,
31+ max_retries: int | None = None ,
32+ tools: list[Tool | Toolset] | Toolset | None = None ,
33+ tools_strict: bool = False ,
34+ http_client_kwargs: dict[str , Any] | None = None
35+ ) -> None
36+ ```
37+
38+ Creates a ` CometAPIChatGenerator ` instance.
39+
40+ ** Parameters:**
41+
42+ - ** api_key** (<code >Secret</code >) – The API key for authenticating with the CometAPI.
43+ - ** model** (<code >str</code >) – The name of the model to use for chat generation (e.g., ` "gpt-5-mini" ` , ` "grok-3-mini" ` ).
44+ - ** streaming_callback** (<code >StreamingCallbackT | None</code >) – An optional callable invoked with each chunk of a streaming response.
45+ - ** generation_kwargs** (<code >dict\[ str, Any\] | None</code >) – Optional keyword arguments passed to the underlying generation API call.
46+ - ** timeout** (<code >int | None</code >) – The maximum time in seconds to wait for a response from the API.
47+ - ** max_retries** (<code >int | None</code >) – The maximum number of times to retry a failed API request.
48+ - ** tools** (<code >list\[ Tool | Toolset\] | Toolset | None</code >) – An optional list of tools the model can use.
49+ - ** tools_strict** (<code >bool</code >) – If ` True ` , the model is forced to use one of the provided tools.
50+ - ** http_client_kwargs** (<code >dict\[ str, Any\] | None</code >) – Optional keyword arguments passed to the HTTP client.
51+
52+ #### to_dict
53+
54+ ``` python
55+ to_dict() -> dict[str , Any]
56+ ```
57+
58+ Serialize this component to a dictionary.
59+
60+ ** Returns:**
3761
62+ - <code >dict\[ str, Any\] </code > – The serialized component as a dictionary.
0 commit comments