cometapi-haystack 2.1.0__py3-none-any.whl → 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: cometapi-haystack
3
- Version: 2.1.0
3
+ Version: 3.0.0
4
4
  Summary: Use Comet API with Haystack to build AI applications with 500+ AI models.
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cometapi#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -11,20 +11,21 @@ License-File: LICENSE.txt
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
18
19
  Classifier: Programming Language :: Python :: Implementation :: CPython
19
20
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
- Requires-Python: >=3.10
21
+ Requires-Python: >=3.11
21
22
  Requires-Dist: haystack-ai>=2.23.0
22
23
  Description-Content-Type: text/markdown
23
24
 
24
25
  # cometapi-haystack
25
26
 
26
27
  [![PyPI - Version](https://img.shields.io/pypi/v/cometapi-haystack.svg)](https://pypi.org/project/cometapi-haystack)
27
- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cometapi-haystack.svg)](https://pypi.org/project/cometapihaystack)
28
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cometapi-haystack.svg)](https://pypi.org/project/cometapi-haystack)
28
29
 
29
30
  - [Integration page](https://haystack.deepset.ai/integrations/comet-api)
30
31
  - [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/cometapi/CHANGELOG.md)
@@ -0,0 +1,7 @@
1
+ haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ haystack_integrations/components/generators/cometapi/__init__.py,sha256=NhfpuefQUSWmMQ3oZ0bavRiQ35Z0EdMeXF_-ORCnV1M,203
3
+ haystack_integrations/components/generators/cometapi/chat/chat_generator.py,sha256=knZE84MB6FQUzRxxaJZk7ehet-_WJUwkgIp0x1XjfV8,3849
4
+ cometapi_haystack-3.0.0.dist-info/METADATA,sha256=ywbQbAlJeMRiLTR6CIuZUW7cxhnZ5IOofVx9u430xtc,1963
5
+ cometapi_haystack-3.0.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
6
+ cometapi_haystack-3.0.0.dist-info/licenses/LICENSE.txt,sha256=OrAtTu4aPmrTjKDSTzkSPgo_ji6NOMWO2N9JOTFyAzM,11350
7
+ cometapi_haystack-3.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.28.0
2
+ Generator: hatchling 1.32.4
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -9,7 +9,8 @@
9
9
  "License" shall mean the terms and conditions for use, reproduction,
10
10
  and distribution as defined by Sections 1 through 9 of this document.
11
11
 
12
- "Licensor" shall mean the copyright owner or entity granting the License.
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
13
14
 
14
15
  "Legal Entity" shall mean the union of the acting entity and all
15
16
  other entities that control, are controlled by, or are under common
@@ -34,8 +35,15 @@
34
35
  "Work" shall mean the work of authorship, whether in Source or
35
36
  Object form, made available under the License, as indicated by a
36
37
  copyright notice that is included in or attached to the work
37
- (which shall not include communications that are marked or
38
- designated in writing by the copyright owner as "Not a Contribution").
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
39
47
 
40
48
  "Contribution" shall mean any work of authorship, including
41
49
  the original version of the Work and any modifications or additions
@@ -45,11 +53,11 @@
45
53
  the copyright owner. For the purposes of this definition, "submitted"
46
54
  means any form of electronic, verbal, or written communication sent
47
55
  to the Licensor or its representatives, including but not limited to
48
- communication on electronic mailing lists, source code control
49
- systems, and issue tracking systems that are managed by, or on behalf
50
- of, the Licensor for the purpose of discussing and improving the Work,
51
- but excluding communication that is conspicuously marked or otherwise
52
- designated in writing by the copyright owner as "Not a Contribution".
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
53
61
 
54
62
  "Contributor" shall mean Licensor and any individual or Legal Entity
55
63
  on behalf of whom a Contribution has been received by Licensor and
@@ -58,10 +66,9 @@
58
66
  2. Grant of Copyright License. Subject to the terms and conditions of
59
67
  this License, each Contributor hereby grants to You a perpetual,
60
68
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
61
- copyright license to use, reproduce, modify, distribute, and prepare
62
- Derivative Works of, publicly display, publicly perform, sublicense,
63
- and distribute the Work and such Derivative Works in Source or Object
64
- form.
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
65
72
 
66
73
  3. Grant of Patent License. Subject to the terms and conditions of
67
74
  this License, each Contributor hereby grants to You a perpetual,
@@ -91,8 +98,8 @@
91
98
  stating that You changed the files; and
92
99
 
93
100
  (c) You must retain, in the Source form of any Derivative Works
94
- that You distribute, all copyright, trademark, patent,
95
- attribution and other notices from the Source form of the Work,
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
96
103
  excluding those notices that do not pertain to any part of
97
104
  the Derivative Works; and
98
105
 
@@ -113,7 +120,7 @@
113
120
  that such additional attribution notices cannot be construed
114
121
  as modifying the License.
115
122
 
116
- You may add Your own copyright notice to Your modifications and
123
+ You may add Your own copyright statement to Your modifications and
117
124
  may provide additional or different license terms and conditions
118
125
  for use, reproduction, or distribution of Your modifications, or
119
126
  for any such Derivative Works as a whole, provided Your use,
@@ -155,14 +162,16 @@
155
162
  other commercial damages or losses), even if such Contributor
156
163
  has been advised of the possibility of such damages.
157
164
 
158
- 9. Accepting Warranty or Support. You may choose to offer, and to
159
- charge a fee for, warranty, support, indemnity or other liability
160
- obligations and/or rights consistent with this License. However, in
161
- accepting such obligations, You may act only on Your own behalf and on
162
- Your sole responsibility, not on behalf of any other Contributor, and
163
- only if You agree to indemnify, defend, and hold each Contributor
164
- harmless for any liability incurred by, or claims asserted against,
165
- such Contributor by reason of your accepting any such warranty or support.
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
166
175
 
167
176
  END OF TERMS AND CONDITIONS
168
177
 
@@ -174,8 +183,8 @@
174
183
  the brackets!) The text should be enclosed in the appropriate
175
184
  comment syntax for the file format. We also recommend that a
176
185
  file or class name and description of purpose be included on the
177
- same page as the copyright notice for easier identification within
178
- third-party archives.
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
179
188
 
180
189
  Copyright 2023-present deepset GmbH
181
190
 
@@ -189,4 +198,4 @@
189
198
  distributed under the License is distributed on an "AS IS" BASIS,
190
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
191
200
  See the License for the specific language governing permissions and
192
- limitations under the License.
201
+ limitations under the License.
@@ -1,5 +1,6 @@
1
1
  from typing import Any
2
2
 
3
+ from haystack import component, default_to_dict
3
4
  from haystack.components.generators.chat import OpenAIChatGenerator
4
5
  from haystack.dataclasses import (
5
6
  StreamingCallbackT,
@@ -7,10 +8,12 @@ from haystack.dataclasses import (
7
8
  from haystack.tools import (
8
9
  Tool,
9
10
  Toolset,
11
+ serialize_tools_or_toolset,
10
12
  )
11
- from haystack.utils import Secret
13
+ from haystack.utils import Secret, serialize_callable
12
14
 
13
15
 
16
+ @component
14
17
  class CometAPIChatGenerator(OpenAIChatGenerator):
15
18
  """
16
19
  A chat generator that uses the CometAPI for generating chat responses.
@@ -18,20 +21,6 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
18
21
  This class extends Haystack's OpenAIChatGenerator to specifically interact with the CometAPI.
19
22
  It sets the `api_base_url` to the CometAPI endpoint and allows for all the
20
23
  standard configurations available in the OpenAIChatGenerator.
21
-
22
- :param api_key: The API key for authenticating with the CometAPI. Defaults to
23
- loading from the "COMET_API_KEY" environment variable.
24
- :param model: The name of the model to use for chat generation (e.g., "gpt-5-mini", "grok-3-mini").
25
- Defaults to "gpt-5-mini".
26
- :param streaming_callback: An optional callable that will be called with each chunk of
27
- a streaming response.
28
- :param generation_kwargs: Optional keyword arguments to pass to the underlying generation
29
- API call.
30
- :param timeout: The maximum time in seconds to wait for a response from the API.
31
- :param max_retries: The maximum number of times to retry a failed API request.
32
- :param tools: An optional list of tool definitions that the model can use.
33
- :param tools_strict: If True, the model is forced to use one of the provided tools if a tool call is made.
34
- :param http_client_kwargs: Optional keyword arguments to pass to the HTTP client.
35
24
  """
36
25
 
37
26
  def __init__(
@@ -46,10 +35,24 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
46
35
  tools: list[Tool | Toolset] | Toolset | None = None,
47
36
  tools_strict: bool = False,
48
37
  http_client_kwargs: dict[str, Any] | None = None,
49
- ):
38
+ ) -> None:
39
+ """
40
+ Creates a `CometAPIChatGenerator` instance.
41
+
42
+ :param api_key: The API key for authenticating with the CometAPI.
43
+ :param model: The name of the model to use for chat generation (e.g., `"gpt-5-mini"`, `"grok-3-mini"`).
44
+ :param streaming_callback: An optional callable invoked with each chunk of a streaming response.
45
+ :param generation_kwargs: Optional keyword arguments passed to the underlying generation API call.
46
+ :param timeout: The maximum time in seconds to wait for a response from the API.
47
+ :param max_retries: The maximum number of times to retry a failed API request.
48
+ :param tools: An optional list of tools the model can use.
49
+ :param tools_strict: If `True`, the model is forced to use one of the provided tools.
50
+ :param http_client_kwargs: Optional keyword arguments passed to the HTTP client.
51
+ """
50
52
  api_base_url = "https://api.cometapi.com/v1"
51
53
 
52
- super().__init__(
54
+ # the @component decorator recreates the class, so the zero-argument form of super() cannot be used
55
+ super(CometAPIChatGenerator, self).__init__( # noqa: UP008
53
56
  api_key=api_key,
54
57
  model=model,
55
58
  api_base_url=api_base_url,
@@ -61,3 +64,29 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
61
64
  tools_strict=tools_strict,
62
65
  http_client_kwargs=http_client_kwargs,
63
66
  )
67
+
68
+ def to_dict(self) -> dict[str, Any]:
69
+ """
70
+ Serialize this component to a dictionary.
71
+
72
+ :returns:
73
+ The serialized component as a dictionary.
74
+ """
75
+ callback_name = serialize_callable(self.streaming_callback) if self.streaming_callback else None
76
+
77
+ # if we didn't implement the to_dict method here then the to_dict method of the superclass would be used
78
+ # which would serialize some fields that we don't want to serialize (e.g. the ones we don't have in
79
+ # the __init__)
80
+ # it would be hard to maintain the compatibility as superclass changes
81
+ return default_to_dict(
82
+ self,
83
+ api_key=self.api_key.to_dict(),
84
+ model=self.model,
85
+ streaming_callback=callback_name,
86
+ generation_kwargs=self.generation_kwargs,
87
+ timeout=self.timeout,
88
+ max_retries=self.max_retries,
89
+ tools=serialize_tools_or_toolset(self.tools),
90
+ tools_strict=self.tools_strict,
91
+ http_client_kwargs=self.http_client_kwargs,
92
+ )
@@ -1,7 +0,0 @@
1
- haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- haystack_integrations/components/generators/cometapi/__init__.py,sha256=NhfpuefQUSWmMQ3oZ0bavRiQ35Z0EdMeXF_-ORCnV1M,203
3
- haystack_integrations/components/generators/cometapi/chat/chat_generator.py,sha256=J1L-R52o2xzuMFyYDC0C8d8SYXl-_4iKX4tFA-6moug,2621
4
- cometapi_haystack-2.1.0.dist-info/METADATA,sha256=ezb2VZd9IXTFYNzqOEubn_L1HZ0r8KGTboTf4xcniws,1911
5
- cometapi_haystack-2.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- cometapi_haystack-2.1.0.dist-info/licenses/LICENSE.txt,sha256=nJOjilTInDpTuBqBSK2Aqb8SsVXTcy2oZpaZPuxDu18,10807
7
- cometapi_haystack-2.1.0.dist-info/RECORD,,