cometapi-haystack 2.1.0__tar.gz → 3.0.0__tar.gz
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.
- cometapi_haystack-3.0.0/CHANGELOG.md +69 -0
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/LICENSE.txt +35 -26
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/PKG-INFO +6 -5
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/README.md +1 -1
- cometapi_haystack-3.0.0/pydoc/config_docusaurus.yml +13 -0
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/pyproject.toml +18 -5
- cometapi_haystack-3.0.0/src/haystack_integrations/components/generators/cometapi/chat/chat_generator.py +92 -0
- cometapi_haystack-3.0.0/tests/conftest.py +11 -0
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/tests/test_cometapi_chat_generator.py +34 -100
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/tests/test_cometapi_chat_generator_async.py +5 -2
- cometapi_haystack-2.1.0/CHANGELOG.md +0 -34
- cometapi_haystack-2.1.0/pydoc/config_docusaurus.yml +0 -28
- cometapi_haystack-2.1.0/src/haystack_integrations/components/generators/cometapi/chat/chat_generator.py +0 -63
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/.gitignore +0 -0
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/src/haystack_integrations/components/generators/cometapi/__init__.py +0 -0
- {cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/src/haystack_integrations/components/generators/py.typed +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [integrations/cometapi-v2.1.1] - 2026-07-13
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- *(cometapi)* Make CometAPIChatGenerator deserializable in pipelines (#3542)
|
|
8
|
+
- Support Haystack 3.0's lazy OpenAI client initialization in OpenAI-inheriting generators (#3536)
|
|
9
|
+
|
|
10
|
+
### 📚 Documentation
|
|
11
|
+
|
|
12
|
+
- Simplify pydoc configs (#2855)
|
|
13
|
+
|
|
14
|
+
### 🧪 Testing
|
|
15
|
+
|
|
16
|
+
- Test compatible integrations with python 3.14; update pyproject (#3001)
|
|
17
|
+
- Track test coverage for all integrations (#3065)
|
|
18
|
+
- Trust test modules under Haystack 3.0's deserialization allowlist (#3537)
|
|
19
|
+
- Make Tool/Agent serialization assertions version-agnostic for Haystack 2.x/3.x (#3533)
|
|
20
|
+
- Guard ToolInvoker imports so chat-generator tests run under Haystack 3.0 (#3535)
|
|
21
|
+
- Fix tests for integrations that inherit from the OpenAIChatGenerator (#3583)
|
|
22
|
+
|
|
23
|
+
### 🧹 Chores
|
|
24
|
+
|
|
25
|
+
- Enable ANN ruff ruleset for cometapi integration (#2984)
|
|
26
|
+
- Enforce ruff docstring rules (D102/D103/D205/D209/D213/D417/D419) in first 10 integrations (#3008)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [integrations/cometapi-v2.1.0] - 2026-01-28
|
|
30
|
+
|
|
31
|
+
### 🧹 Chores
|
|
32
|
+
|
|
33
|
+
- CometAPI - upgrade to Haystack 2.23 and remove special delta handling (#2786)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [integrations/cometapi-v2.0.1] - 2026-01-19
|
|
37
|
+
|
|
38
|
+
### 🐛 Bug Fixes
|
|
39
|
+
|
|
40
|
+
- `CometAPIChatGenerator` - handle `delta` set to `None` (#2759)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [integrations/cometapi-v2.0.0] - 2026-01-09
|
|
44
|
+
|
|
45
|
+
### 🧹 Chores
|
|
46
|
+
|
|
47
|
+
- Remove Readme API CI workflow and configs (#2573)
|
|
48
|
+
- Make fmt command more forgiving (#2671)
|
|
49
|
+
- [**breaking**] Cometapi - drop Python 3.9 and use X|Y typing (#2697)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## [integrations/cometapi-v1.1.0] - 2025-11-26
|
|
53
|
+
|
|
54
|
+
### 🧹 Chores
|
|
55
|
+
|
|
56
|
+
- Update CometAPIChatGenerator default model to gpt-5-mini and remove e… (#2559)
|
|
57
|
+
|
|
58
|
+
### 🌀 Miscellaneous
|
|
59
|
+
|
|
60
|
+
- Add missing config file for Docusaurus sync (#2505)
|
|
61
|
+
- Adopt PEP 585 type hinting (part 3) (#2510)
|
|
62
|
+
|
|
63
|
+
## [integrations/cometapi-v1.0.0] - 2025-11-11
|
|
64
|
+
|
|
65
|
+
### 🚀 Features
|
|
66
|
+
|
|
67
|
+
- Add CometAPI integration with CometAPIChatGenerator class and configuration (#2345)
|
|
68
|
+
|
|
69
|
+
<!-- generated by git-cliff -->
|
|
@@ -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
|
|
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
|
-
(
|
|
38
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
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,
|
|
95
|
-
attribution
|
|
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
|
|
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
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
|
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,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: cometapi-haystack
|
|
3
|
-
Version:
|
|
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.
|
|
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
|
[](https://pypi.org/project/cometapi-haystack)
|
|
27
|
-
[](https://pypi.org/project/
|
|
28
|
+
[](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)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# cometapi-haystack
|
|
2
2
|
|
|
3
3
|
[](https://pypi.org/project/cometapi-haystack)
|
|
4
|
-
[](https://pypi.org/project/
|
|
4
|
+
[](https://pypi.org/project/cometapi-haystack)
|
|
5
5
|
|
|
6
6
|
- [Integration page](https://haystack.deepset.ai/integrations/comet-api)
|
|
7
7
|
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/cometapi/CHANGELOG.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
loaders:
|
|
2
|
+
- modules:
|
|
3
|
+
- haystack_integrations.components.generators.cometapi.chat.chat_generator
|
|
4
|
+
search_path: [../src]
|
|
5
|
+
processors:
|
|
6
|
+
- type: filter
|
|
7
|
+
documented_only: true
|
|
8
|
+
skip_empty_modules: true
|
|
9
|
+
renderer:
|
|
10
|
+
description: Comet API integration for Haystack
|
|
11
|
+
id: integrations-cometapi
|
|
12
|
+
filename: cometapi.md
|
|
13
|
+
title: Comet API
|
|
@@ -7,7 +7,7 @@ name = "cometapi-haystack"
|
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = 'Use Comet API with Haystack to build AI applications with 500+ AI models.'
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
keywords = []
|
|
13
13
|
authors = [
|
|
@@ -18,10 +18,11 @@ classifiers = [
|
|
|
18
18
|
"License :: OSI Approved :: Apache Software License",
|
|
19
19
|
"Development Status :: 4 - Beta",
|
|
20
20
|
"Programming Language :: Python",
|
|
21
|
-
"Programming Language :: Python :: 3.10",
|
|
22
21
|
"Programming Language :: Python :: 3.11",
|
|
23
22
|
"Programming Language :: Python :: 3.12",
|
|
24
23
|
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Programming Language :: Python :: 3.15",
|
|
25
26
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
26
27
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
27
28
|
]
|
|
@@ -48,7 +49,7 @@ installer = "uv"
|
|
|
48
49
|
dependencies = ["haystack-pydoc-tools", "ruff"]
|
|
49
50
|
|
|
50
51
|
[tool.hatch.envs.default.scripts]
|
|
51
|
-
docs = ["pydoc
|
|
52
|
+
docs = ["haystack-pydoc pydoc/config_docusaurus.yml"]
|
|
52
53
|
fmt = "ruff check --fix {args}; ruff format {args}"
|
|
53
54
|
fmt-check = "ruff check {args} && ruff format --check {args}"
|
|
54
55
|
|
|
@@ -67,7 +68,8 @@ dependencies = [
|
|
|
67
68
|
unit = 'pytest -m "not integration" {args:tests}'
|
|
68
69
|
integration = 'pytest -m "integration" {args:tests}'
|
|
69
70
|
all = 'pytest {args:tests}'
|
|
70
|
-
cov-retry = '
|
|
71
|
+
unit-cov-retry = 'pytest --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x -m "not integration" {args:tests}'
|
|
72
|
+
integration-cov-append-retry = 'pytest --cov=haystack_integrations --cov-append --reruns 3 --reruns-delay 30 -x -m "integration" {args:tests}'
|
|
71
73
|
|
|
72
74
|
types = "mypy -p haystack_integrations.components.generators.cometapi {args}"
|
|
73
75
|
|
|
@@ -84,9 +86,17 @@ line-length = 120
|
|
|
84
86
|
[tool.ruff.lint]
|
|
85
87
|
select = [
|
|
86
88
|
"A",
|
|
89
|
+
"ANN",
|
|
87
90
|
"ARG",
|
|
88
91
|
"B",
|
|
89
92
|
"C",
|
|
93
|
+
"D102", # Missing docstring in public method
|
|
94
|
+
"D103", # Missing docstring in public function
|
|
95
|
+
"D205", # 1 blank line required between summary line and description
|
|
96
|
+
"D209", # Closing triple quotes go to new line
|
|
97
|
+
"D213", # summary lines must be positioned on the second physical line of the docstring
|
|
98
|
+
"D417", # Missing argument descriptions in the docstring
|
|
99
|
+
"D419", # Docstring is empty
|
|
90
100
|
"DTZ",
|
|
91
101
|
"E",
|
|
92
102
|
"EM",
|
|
@@ -110,6 +120,7 @@ select = [
|
|
|
110
120
|
"YTT",
|
|
111
121
|
]
|
|
112
122
|
ignore = [
|
|
123
|
+
"ANN401", # Allow Any - used legitimately for dynamic types and SDK boundaries
|
|
113
124
|
# Allow non-abstract empty methods in abstract base classes
|
|
114
125
|
"B027",
|
|
115
126
|
# Allow boolean positional values in function calls, like `dict.get(... True)`
|
|
@@ -124,6 +135,7 @@ ignore = [
|
|
|
124
135
|
"PLR0912",
|
|
125
136
|
"PLR0913",
|
|
126
137
|
"PLR0915",
|
|
138
|
+
"PLR0917",
|
|
127
139
|
# Ignore unused params
|
|
128
140
|
"ARG001",
|
|
129
141
|
"ARG002",
|
|
@@ -140,13 +152,14 @@ ban-relative-imports = "parents"
|
|
|
140
152
|
|
|
141
153
|
[tool.ruff.lint.per-file-ignores]
|
|
142
154
|
# Tests can use magic values, assertions, and relative imports
|
|
143
|
-
"tests/**/*" = ["PLR2004", "S101", "TID252"]
|
|
155
|
+
"tests/**/*" = ["PLR2004", "S101", "TID252", "D", "ANN"]
|
|
144
156
|
# Examples can use print statements
|
|
145
157
|
"examples/**/*" = ["T201"]
|
|
146
158
|
|
|
147
159
|
[tool.coverage.run]
|
|
148
160
|
source = ["haystack_integrations"]
|
|
149
161
|
branch = true
|
|
162
|
+
relative_files = true
|
|
150
163
|
parallel = true
|
|
151
164
|
|
|
152
165
|
[tool.coverage.report]
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from haystack import component, default_to_dict
|
|
4
|
+
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
5
|
+
from haystack.dataclasses import (
|
|
6
|
+
StreamingCallbackT,
|
|
7
|
+
)
|
|
8
|
+
from haystack.tools import (
|
|
9
|
+
Tool,
|
|
10
|
+
Toolset,
|
|
11
|
+
serialize_tools_or_toolset,
|
|
12
|
+
)
|
|
13
|
+
from haystack.utils import Secret, serialize_callable
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@component
|
|
17
|
+
class CometAPIChatGenerator(OpenAIChatGenerator):
|
|
18
|
+
"""
|
|
19
|
+
A chat generator that uses the CometAPI for generating chat responses.
|
|
20
|
+
|
|
21
|
+
This class extends Haystack's OpenAIChatGenerator to specifically interact with the CometAPI.
|
|
22
|
+
It sets the `api_base_url` to the CometAPI endpoint and allows for all the
|
|
23
|
+
standard configurations available in the OpenAIChatGenerator.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
*,
|
|
29
|
+
api_key: Secret = Secret.from_env_var("COMET_API_KEY"),
|
|
30
|
+
model: str = "gpt-5-mini",
|
|
31
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
32
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
33
|
+
timeout: int | None = None,
|
|
34
|
+
max_retries: int | None = None,
|
|
35
|
+
tools: list[Tool | Toolset] | Toolset | None = None,
|
|
36
|
+
tools_strict: bool = False,
|
|
37
|
+
http_client_kwargs: dict[str, Any] | None = None,
|
|
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
|
+
"""
|
|
52
|
+
api_base_url = "https://api.cometapi.com/v1"
|
|
53
|
+
|
|
54
|
+
# the @component decorator recreates the class, so the zero-argument form of super() cannot be used
|
|
55
|
+
super(CometAPIChatGenerator, self).__init__( # noqa: UP008
|
|
56
|
+
api_key=api_key,
|
|
57
|
+
model=model,
|
|
58
|
+
api_base_url=api_base_url,
|
|
59
|
+
streaming_callback=streaming_callback,
|
|
60
|
+
generation_kwargs=generation_kwargs,
|
|
61
|
+
timeout=timeout,
|
|
62
|
+
max_retries=max_retries,
|
|
63
|
+
tools=tools,
|
|
64
|
+
tools_strict=tools_strict,
|
|
65
|
+
http_client_kwargs=http_client_kwargs,
|
|
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
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@pytest.fixture(autouse=True)
|
|
5
|
+
def allow_deserialization_of_test_modules(monkeypatch):
|
|
6
|
+
"""
|
|
7
|
+
haystack-ai >= 3.0 refuses to deserialize classes and callables from modules outside its
|
|
8
|
+
trusted-module allowlist. Tools and callbacks defined in the test modules live outside that
|
|
9
|
+
allowlist, so trust them explicitly; haystack-ai 2.x ignores this environment variable.
|
|
10
|
+
"""
|
|
11
|
+
monkeypatch.setenv("HAYSTACK_DESERIALIZATION_ALLOWLIST", "tests,test_*")
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from dataclasses import asdict
|
|
3
2
|
from datetime import datetime
|
|
4
3
|
from unittest.mock import patch
|
|
5
4
|
|
|
6
5
|
import pytest
|
|
7
6
|
import pytz
|
|
8
7
|
from haystack import Pipeline
|
|
8
|
+
from haystack.components.agents import Agent
|
|
9
9
|
from haystack.components.generators.utils import print_streaming_chunk
|
|
10
|
-
from haystack.components.tools import ToolInvoker
|
|
11
10
|
from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk, ToolCall
|
|
12
11
|
from haystack.tools import Tool
|
|
13
12
|
from haystack.utils.auth import Secret
|
|
@@ -88,16 +87,24 @@ class TestCometAPIChatGenerator:
|
|
|
88
87
|
def test_init_default(self, monkeypatch):
|
|
89
88
|
monkeypatch.setenv("COMET_API_KEY", "test-api-key")
|
|
90
89
|
component = CometAPIChatGenerator()
|
|
91
|
-
assert component.
|
|
90
|
+
assert component.api_key.resolve_value() == "test-api-key"
|
|
92
91
|
assert component.model == "gpt-5-mini"
|
|
93
92
|
assert component.api_base_url == "https://api.cometapi.com/v1"
|
|
94
93
|
assert component.streaming_callback is None
|
|
95
94
|
assert not component.generation_kwargs
|
|
96
95
|
|
|
96
|
+
def test_warm_up(self, monkeypatch):
|
|
97
|
+
monkeypatch.setenv("COMET_API_KEY", "test-api-key")
|
|
98
|
+
component = CometAPIChatGenerator()
|
|
99
|
+
component.warm_up() # with haystack-ai >= 3.0 the client is created during warm-up
|
|
100
|
+
assert component.client.api_key == "test-api-key"
|
|
101
|
+
|
|
97
102
|
def test_init_fail_wo_api_key(self, monkeypatch):
|
|
98
103
|
monkeypatch.delenv("COMET_API_KEY", raising=False)
|
|
99
104
|
with pytest.raises(ValueError, match=r"None of the .* environment variables are set"):
|
|
100
|
-
|
|
105
|
+
# haystack-ai 2.x raises at init; haystack-ai >= 3.0 raises when the client is created in warm_up
|
|
106
|
+
component = CometAPIChatGenerator()
|
|
107
|
+
component.warm_up()
|
|
101
108
|
|
|
102
109
|
def test_init_with_parameters(self):
|
|
103
110
|
component = CometAPIChatGenerator(
|
|
@@ -106,7 +113,7 @@ class TestCometAPIChatGenerator:
|
|
|
106
113
|
streaming_callback=print_streaming_chunk,
|
|
107
114
|
generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"},
|
|
108
115
|
)
|
|
109
|
-
assert component.
|
|
116
|
+
assert component.api_key.resolve_value() == "test-api-key"
|
|
110
117
|
assert component.model == "gpt-5-mini"
|
|
111
118
|
assert component.streaming_callback is print_streaming_chunk
|
|
112
119
|
assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"}
|
|
@@ -125,7 +132,6 @@ class TestCometAPIChatGenerator:
|
|
|
125
132
|
"api_key": {"env_vars": ["COMET_API_KEY"], "strict": True, "type": "env_var"},
|
|
126
133
|
"model": "gpt-5-mini",
|
|
127
134
|
"streaming_callback": None,
|
|
128
|
-
"api_base_url": "https://api.cometapi.com/v1",
|
|
129
135
|
"generation_kwargs": {},
|
|
130
136
|
"timeout": None,
|
|
131
137
|
"max_retries": None,
|
|
@@ -158,7 +164,6 @@ class TestCometAPIChatGenerator:
|
|
|
158
164
|
expected_params = {
|
|
159
165
|
"api_key": {"env_vars": ["ENV_VAR"], "strict": True, "type": "env_var"},
|
|
160
166
|
"model": "gpt-5-mini",
|
|
161
|
-
"api_base_url": "https://api.cometapi.com/v1",
|
|
162
167
|
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
|
|
163
168
|
"generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
|
|
164
169
|
"timeout": 10,
|
|
@@ -196,22 +201,6 @@ class TestCometAPIChatGenerator:
|
|
|
196
201
|
assert component.timeout == 10
|
|
197
202
|
assert component.max_retries == 10
|
|
198
203
|
|
|
199
|
-
def test_from_dict_fail_wo_env_var(self, monkeypatch):
|
|
200
|
-
monkeypatch.delenv("COMET_API_KEY", raising=False)
|
|
201
|
-
data = {
|
|
202
|
-
"type": ("haystack_integrations.components.generators.cometapi.chat.chat_generator.CometAPIChatGenerator"),
|
|
203
|
-
"init_parameters": {
|
|
204
|
-
"api_key": {"env_vars": ["COMET_API_KEY"], "strict": True, "type": "env_var"},
|
|
205
|
-
"model": "gpt-5-mini",
|
|
206
|
-
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
|
|
207
|
-
"generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
|
|
208
|
-
"timeout": 10,
|
|
209
|
-
"max_retries": 10,
|
|
210
|
-
},
|
|
211
|
-
}
|
|
212
|
-
with pytest.raises(ValueError, match=r"None of the .* environment variables are set"):
|
|
213
|
-
CometAPIChatGenerator.from_dict(data)
|
|
214
|
-
|
|
215
204
|
def test_run(self, chat_messages, mock_chat_completion, monkeypatch):
|
|
216
205
|
monkeypatch.setenv("COMET_API_KEY", "fake-api-key")
|
|
217
206
|
component = CometAPIChatGenerator()
|
|
@@ -392,29 +381,15 @@ class TestCometAPIChatGenerator:
|
|
|
392
381
|
reason="Export an env var called COMET_API_KEY containing the OpenAI API key to run this test.",
|
|
393
382
|
)
|
|
394
383
|
@pytest.mark.integration
|
|
395
|
-
def
|
|
384
|
+
def test_agent_with_cometapi_chat_generator(self, tools):
|
|
396
385
|
"""
|
|
397
|
-
Test that the CometAPIChatGenerator component can
|
|
386
|
+
Test that the CometAPIChatGenerator component can drive tool calls in an Agent
|
|
398
387
|
"""
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
pipeline.add_component("tool_invoker", ToolInvoker(tools=tools))
|
|
388
|
+
agent = Agent(chat_generator=CometAPIChatGenerator(), tools=tools)
|
|
389
|
+
result = agent.run(messages=[ChatMessage.from_user("What's the weather like in Paris?")])
|
|
402
390
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
results = pipeline.run(
|
|
406
|
-
data={
|
|
407
|
-
"generator": {
|
|
408
|
-
"messages": [ChatMessage.from_user("What's the weather like in Paris?")],
|
|
409
|
-
"generation_kwargs": {"tool_choice": "auto"},
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
)
|
|
413
|
-
|
|
414
|
-
assert (
|
|
415
|
-
"The weather in Paris is sunny and 32°C"
|
|
416
|
-
== results["tool_invoker"]["tool_messages"][0].tool_call_result.result
|
|
417
|
-
)
|
|
391
|
+
tool_results = [msg.tool_call_result.result for msg in result["messages"] if msg.tool_call_result]
|
|
392
|
+
assert "The weather in Paris is sunny and 32°C" in tool_results
|
|
418
393
|
|
|
419
394
|
def test_serde_in_pipeline(self, monkeypatch):
|
|
420
395
|
"""
|
|
@@ -445,6 +420,11 @@ class TestCometAPIChatGenerator:
|
|
|
445
420
|
|
|
446
421
|
# Get pipeline dictionary and verify its structure
|
|
447
422
|
pipeline_dict = pipeline.to_dict()
|
|
423
|
+
|
|
424
|
+
# the Tool serialization format is owned by haystack-ai and varies across its versions; the
|
|
425
|
+
# dumps/loads round-trip below covers the tools, so exclude them from the pinned-dict comparison
|
|
426
|
+
tools_entries = pipeline_dict["components"]["generator"]["init_parameters"].pop("tools")
|
|
427
|
+
assert len(tools_entries) == 1
|
|
448
428
|
expected_dict = {
|
|
449
429
|
"metadata": {},
|
|
450
430
|
"max_runs_per_component": 100,
|
|
@@ -456,23 +436,10 @@ class TestCometAPIChatGenerator:
|
|
|
456
436
|
"init_parameters": {
|
|
457
437
|
"model": "gpt-5-mini",
|
|
458
438
|
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
|
|
459
|
-
"api_base_url": "https://api.cometapi.com/v1",
|
|
460
|
-
"organization": None,
|
|
461
439
|
"generation_kwargs": {"temperature": 0.7},
|
|
462
440
|
"api_key": {"type": "env_var", "env_vars": ["COMET_API_KEY"], "strict": True},
|
|
463
441
|
"timeout": None,
|
|
464
442
|
"max_retries": None,
|
|
465
|
-
"tools": [
|
|
466
|
-
{
|
|
467
|
-
"type": "haystack.tools.tool.Tool",
|
|
468
|
-
"data": {
|
|
469
|
-
"name": "weather",
|
|
470
|
-
"description": "useful to determine the weather in a given location",
|
|
471
|
-
"parameters": {"city": {"type": "string"}},
|
|
472
|
-
"function": "test_cometapi_chat_generator.weather",
|
|
473
|
-
},
|
|
474
|
-
}
|
|
475
|
-
],
|
|
476
443
|
"tools_strict": False,
|
|
477
444
|
"http_client_kwargs": None,
|
|
478
445
|
},
|
|
@@ -485,25 +452,15 @@ class TestCometAPIChatGenerator:
|
|
|
485
452
|
if not hasattr(pipeline, "_connection_type_validation"):
|
|
486
453
|
expected_dict.pop("connection_type_validation")
|
|
487
454
|
|
|
488
|
-
# add outputs_to_string, inputs_from_state and outputs_to_state tool parameters for compatibility with
|
|
489
|
-
# haystack-ai>=2.12.0
|
|
490
|
-
if hasattr(tool, "outputs_to_string"):
|
|
491
|
-
expected_dict["components"]["generator"]["init_parameters"]["tools"][0]["data"]["outputs_to_string"] = (
|
|
492
|
-
tool.outputs_to_string
|
|
493
|
-
)
|
|
494
|
-
if hasattr(tool, "inputs_from_state"):
|
|
495
|
-
expected_dict["components"]["generator"]["init_parameters"]["tools"][0]["data"]["inputs_from_state"] = (
|
|
496
|
-
tool.inputs_from_state
|
|
497
|
-
)
|
|
498
|
-
if hasattr(tool, "outputs_to_state"):
|
|
499
|
-
expected_dict["components"]["generator"]["init_parameters"]["tools"][0]["data"]["outputs_to_state"] = (
|
|
500
|
-
tool.outputs_to_state
|
|
501
|
-
)
|
|
502
|
-
|
|
503
455
|
assert pipeline_dict == expected_dict
|
|
504
456
|
|
|
457
|
+
# Test YAML serialization/deserialization
|
|
458
|
+
pipeline_yaml = pipeline.dumps()
|
|
459
|
+
new_pipeline = Pipeline.loads(pipeline_yaml)
|
|
460
|
+
assert new_pipeline == pipeline
|
|
461
|
+
|
|
505
462
|
# Verify the loaded pipeline's generator has the same configuration
|
|
506
|
-
loaded_generator =
|
|
463
|
+
loaded_generator = new_pipeline.get_component("generator")
|
|
507
464
|
assert loaded_generator.model == generator.model
|
|
508
465
|
assert loaded_generator.generation_kwargs == generator.generation_kwargs
|
|
509
466
|
assert loaded_generator.streaming_callback == generator.streaming_callback
|
|
@@ -833,32 +790,9 @@ class TestChatCompletionChunkConversion:
|
|
|
833
790
|
assert result.meta["index"] == 0
|
|
834
791
|
assert result.meta["completion_start_time"] is not None
|
|
835
792
|
|
|
836
|
-
# Normalize usage details before asserting
|
|
837
793
|
usage = result.meta["usage"]
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
# For dataclass fallback
|
|
845
|
-
if not isinstance(usage["completion_tokens_details"], dict):
|
|
846
|
-
usage["completion_tokens_details"] = asdict(usage["completion_tokens_details"])
|
|
847
|
-
if not isinstance(usage["prompt_tokens_details"], dict):
|
|
848
|
-
usage["prompt_tokens_details"] = asdict(usage["prompt_tokens_details"])
|
|
849
|
-
|
|
850
|
-
assert usage == {
|
|
851
|
-
"completion_tokens": 42,
|
|
852
|
-
"prompt_tokens": 55,
|
|
853
|
-
"total_tokens": 97,
|
|
854
|
-
"completion_tokens_details": {
|
|
855
|
-
"accepted_prediction_tokens": None,
|
|
856
|
-
"audio_tokens": None,
|
|
857
|
-
"reasoning_tokens": 0,
|
|
858
|
-
"rejected_prediction_tokens": None,
|
|
859
|
-
},
|
|
860
|
-
"prompt_tokens_details": {
|
|
861
|
-
"audio_tokens": None,
|
|
862
|
-
"cached_tokens": 0,
|
|
863
|
-
},
|
|
864
|
-
}
|
|
794
|
+
assert usage["completion_tokens"] == 42
|
|
795
|
+
assert usage["prompt_tokens"] == 55
|
|
796
|
+
assert usage["total_tokens"] == 97
|
|
797
|
+
assert usage["completion_tokens_details"]["reasoning_tokens"] == 0
|
|
798
|
+
assert usage["prompt_tokens_details"]["cached_tokens"] == 0
|
{cometapi_haystack-2.1.0 → cometapi_haystack-3.0.0}/tests/test_cometapi_chat_generator_async.py
RENAMED
|
@@ -83,14 +83,17 @@ def mock_async_chat_completion():
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
class TestCometAPIChatGeneratorAsync:
|
|
86
|
-
|
|
86
|
+
@pytest.mark.asyncio
|
|
87
|
+
async def test_warm_up_async(self, monkeypatch):
|
|
87
88
|
monkeypatch.setenv("COMET_API_KEY", "test-api-key")
|
|
88
89
|
component = CometAPIChatGenerator()
|
|
90
|
+
if hasattr(component, "warm_up_async"):
|
|
91
|
+
# haystack-ai >= 3.0 creates the async client during async warm-up
|
|
92
|
+
await component.warm_up_async()
|
|
89
93
|
|
|
90
94
|
assert isinstance(component.async_client, AsyncOpenAI)
|
|
91
95
|
assert component.async_client.api_key == "test-api-key"
|
|
92
96
|
assert component.async_client.base_url == "https://api.cometapi.com/v1/"
|
|
93
|
-
assert not component.generation_kwargs
|
|
94
97
|
|
|
95
98
|
@pytest.mark.asyncio
|
|
96
99
|
async def test_run_async(self, chat_messages, mock_async_chat_completion, monkeypatch):
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [integrations/cometapi-v2.0.1] - 2026-01-19
|
|
4
|
-
|
|
5
|
-
### 🐛 Bug Fixes
|
|
6
|
-
|
|
7
|
-
- `CometAPIChatGenerator` - handle `delta` set to `None` (#2759)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## [integrations/cometapi-v2.0.0] - 2026-01-09
|
|
11
|
-
|
|
12
|
-
### 🧹 Chores
|
|
13
|
-
|
|
14
|
-
- Remove Readme API CI workflow and configs (#2573)
|
|
15
|
-
- Make fmt command more forgiving (#2671)
|
|
16
|
-
- [**breaking**] Cometapi - drop Python 3.9 and use X|Y typing (#2697)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## [integrations/cometapi-v1.1.0] - 2025-11-26
|
|
20
|
-
|
|
21
|
-
### 🚀 Features
|
|
22
|
-
|
|
23
|
-
- Add CometAPI integration with CometAPIChatGenerator class and configuration (#2345)
|
|
24
|
-
|
|
25
|
-
### 🧹 Chores
|
|
26
|
-
|
|
27
|
-
- Update CometAPIChatGenerator default model to gpt-5-mini and remove e… (#2559)
|
|
28
|
-
|
|
29
|
-
### 🌀 Miscellaneous
|
|
30
|
-
|
|
31
|
-
- Add missing config file for Docusaurus sync (#2505)
|
|
32
|
-
- Adopt PEP 585 type hinting (part 3) (#2510)
|
|
33
|
-
|
|
34
|
-
<!-- generated by git-cliff -->
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
loaders:
|
|
2
|
-
- ignore_when_discovered:
|
|
3
|
-
- __init__
|
|
4
|
-
modules:
|
|
5
|
-
- haystack_integrations.components.generators.cometapi.chat.chat_generator
|
|
6
|
-
search_path:
|
|
7
|
-
- ../src
|
|
8
|
-
type: haystack_pydoc_tools.loaders.CustomPythonLoader
|
|
9
|
-
processors:
|
|
10
|
-
- do_not_filter_modules: false
|
|
11
|
-
documented_only: true
|
|
12
|
-
expression: null
|
|
13
|
-
skip_empty_modules: true
|
|
14
|
-
type: filter
|
|
15
|
-
- type: smart
|
|
16
|
-
- type: crossref
|
|
17
|
-
renderer:
|
|
18
|
-
description: Comet API integration for Haystack
|
|
19
|
-
id: integrations-cometapi
|
|
20
|
-
markdown:
|
|
21
|
-
add_member_class_prefix: false
|
|
22
|
-
add_method_class_prefix: true
|
|
23
|
-
classdef_code_block: false
|
|
24
|
-
descriptive_class_title: false
|
|
25
|
-
descriptive_module_title: true
|
|
26
|
-
filename: cometapi.md
|
|
27
|
-
title: Comet API
|
|
28
|
-
type: haystack_pydoc_tools.renderers.DocusaurusRenderer
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
4
|
-
from haystack.dataclasses import (
|
|
5
|
-
StreamingCallbackT,
|
|
6
|
-
)
|
|
7
|
-
from haystack.tools import (
|
|
8
|
-
Tool,
|
|
9
|
-
Toolset,
|
|
10
|
-
)
|
|
11
|
-
from haystack.utils import Secret
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class CometAPIChatGenerator(OpenAIChatGenerator):
|
|
15
|
-
"""
|
|
16
|
-
A chat generator that uses the CometAPI for generating chat responses.
|
|
17
|
-
|
|
18
|
-
This class extends Haystack's OpenAIChatGenerator to specifically interact with the CometAPI.
|
|
19
|
-
It sets the `api_base_url` to the CometAPI endpoint and allows for all the
|
|
20
|
-
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
|
-
"""
|
|
36
|
-
|
|
37
|
-
def __init__(
|
|
38
|
-
self,
|
|
39
|
-
*,
|
|
40
|
-
api_key: Secret = Secret.from_env_var("COMET_API_KEY"),
|
|
41
|
-
model: str = "gpt-5-mini",
|
|
42
|
-
streaming_callback: StreamingCallbackT | None = None,
|
|
43
|
-
generation_kwargs: dict[str, Any] | None = None,
|
|
44
|
-
timeout: int | None = None,
|
|
45
|
-
max_retries: int | None = None,
|
|
46
|
-
tools: list[Tool | Toolset] | Toolset | None = None,
|
|
47
|
-
tools_strict: bool = False,
|
|
48
|
-
http_client_kwargs: dict[str, Any] | None = None,
|
|
49
|
-
):
|
|
50
|
-
api_base_url = "https://api.cometapi.com/v1"
|
|
51
|
-
|
|
52
|
-
super().__init__(
|
|
53
|
-
api_key=api_key,
|
|
54
|
-
model=model,
|
|
55
|
-
api_base_url=api_base_url,
|
|
56
|
-
streaming_callback=streaming_callback,
|
|
57
|
-
generation_kwargs=generation_kwargs,
|
|
58
|
-
timeout=timeout,
|
|
59
|
-
max_retries=max_retries,
|
|
60
|
-
tools=tools,
|
|
61
|
-
tools_strict=tools_strict,
|
|
62
|
-
http_client_kwargs=http_client_kwargs,
|
|
63
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|