cometapi-haystack 1.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.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: cometapi-haystack
3
+ Version: 1.0.0
4
+ Summary: Use Comet API with Haystack to build AI applications with 500+ AI models.
5
+ Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cometapi#readme
6
+ Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
7
+ Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cometapi
8
+ Author-email: deepset GmbH <info@deepset.ai>, Gary Badwal <gurpreet071999@gmail.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE.txt
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: Implementation :: CPython
20
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
21
+ Requires-Python: >=3.9
22
+ Requires-Dist: haystack-ai>=2.13.2
23
+ Description-Content-Type: text/markdown
24
+
25
+ # cometapi-haystack
26
+
27
+ [![PyPI - Version](https://img.shields.io/pypi/v/cometapi-haystack.svg)](https://pypi.org/project/cometapi-haystack)
28
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cometapi-haystack.svg)](https://pypi.org/project/cometapihaystack)
29
+
30
+ - [Integration page](https://haystack.deepset.ai/integrations/comet-api)
31
+ - [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/cometapi/CHANGELOG.md)
32
+
33
+ ---
34
+
35
+ ## Contributing
36
+
37
+ Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
38
+
39
+ To run integration tests locally, you need to export the `COMET_API_KEY` environment variable.
@@ -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=X6xJlD2RrKwvdRmZBYlEXzsy4UxWVfcKiPZoYULkOGs,2661
4
+ cometapi_haystack-1.0.0.dist-info/METADATA,sha256=XwTIsG7oOesOYAnPyK7anInwe0iR1oXPKhMnf54OAkA,1960
5
+ cometapi_haystack-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ cometapi_haystack-1.0.0.dist-info/licenses/LICENSE.txt,sha256=nJOjilTInDpTuBqBSK2Aqb8SsVXTcy2oZpaZPuxDu18,10807
7
+ cometapi_haystack-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,192 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity granting the License.
13
+
14
+ "Legal Entity" shall mean the union of the acting entity and all
15
+ other entities that control, are controlled by, or are under common
16
+ control with that entity. For the purposes of this definition,
17
+ "control" means (i) the power, direct or indirect, to cause the
18
+ direction or management of such entity, whether by contract or
19
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity
23
+ exercising permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications,
26
+ including but not limited to software source code, documentation
27
+ source, and configuration files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical
30
+ transformation or translation of a Source form, including but
31
+ not limited to compiled object code, generated documentation,
32
+ and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or
35
+ Object form, made available under the License, as indicated by a
36
+ 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").
39
+
40
+ "Contribution" shall mean any work of authorship, including
41
+ the original version of the Work and any modifications or additions
42
+ to that Work or Derivative Works thereof, that is intentionally
43
+ submitted to Licensor for inclusion in the Work by the copyright owner
44
+ or by an individual or Legal Entity authorized to submit on behalf of
45
+ the copyright owner. For the purposes of this definition, "submitted"
46
+ means any form of electronic, verbal, or written communication sent
47
+ 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".
53
+
54
+ "Contributor" shall mean Licensor and any individual or Legal Entity
55
+ on behalf of whom a Contribution has been received by Licensor and
56
+ subsequently incorporated within the Work.
57
+
58
+ 2. Grant of Copyright License. Subject to the terms and conditions of
59
+ this License, each Contributor hereby grants to You a perpetual,
60
+ 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.
65
+
66
+ 3. Grant of Patent License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ (except as stated in this section) patent license to make, have made,
70
+ use, offer to sell, sell, import, and otherwise transfer the Work,
71
+ where such license applies only to those patent claims licensable
72
+ by such Contributor that are necessarily infringed by their
73
+ Contribution(s) alone or by combination of their Contribution(s)
74
+ with the Work to which such Contribution(s) was submitted. If You
75
+ institute patent litigation against any entity (including a
76
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
77
+ or a Contribution incorporated within the Work constitutes direct
78
+ or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate
80
+ as of the date such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the
83
+ Work or Derivative Works thereof in any medium, with or without
84
+ modifications, and in Source or Object form, provided that You
85
+ meet the following conditions:
86
+
87
+ (a) You must give any other recipients of the Work or
88
+ Derivative Works a copy of this License; and
89
+
90
+ (b) You must cause any modified files to carry prominent notices
91
+ stating that You changed the files; and
92
+
93
+ (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,
96
+ excluding those notices that do not pertain to any part of
97
+ the Derivative Works; and
98
+
99
+ (d) If the Work includes a "NOTICE" text file as part of its
100
+ distribution, then any Derivative Works that You distribute must
101
+ include a readable copy of the attribution notices contained
102
+ within such NOTICE file, excluding those notices that do not
103
+ pertain to any part of the Derivative Works, in at least one
104
+ of the following places: within a NOTICE text file distributed
105
+ as part of the Derivative Works; within the Source form or
106
+ documentation, if provided along with the Derivative Works; or,
107
+ within a display generated by the Derivative Works, if and
108
+ wherever such third-party notices normally appear. The contents
109
+ of the NOTICE file are for informational purposes only and
110
+ do not modify the License. You may add Your own attribution
111
+ notices within Derivative Works that You distribute, alongside
112
+ or as an addendum to the NOTICE text from the Work, provided
113
+ that such additional attribution notices cannot be construed
114
+ as modifying the License.
115
+
116
+ You may add Your own copyright notice to Your modifications and
117
+ may provide additional or different license terms and conditions
118
+ for use, reproduction, or distribution of Your modifications, or
119
+ for any such Derivative Works as a whole, provided Your use,
120
+ reproduction, and distribution of the Work otherwise complies with
121
+ the conditions stated in this License.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+ Notwithstanding the above, nothing herein shall supersede or modify
128
+ the terms of any separate license agreement you may have executed
129
+ with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor,
133
+ except as required for reasonable and customary use in describing the
134
+ origin of the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
140
+ implied, including, without limitation, any warranties or conditions
141
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
142
+ PARTICULAR PURPOSE. You are solely responsible for determining the
143
+ appropriateness of using or redistributing the Work and assume any
144
+ risks associated with Your exercise of permissions under this License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort (including negligence), contract, or otherwise,
148
+ unless required by applicable law (such as deliberate and grossly
149
+ negligent acts) or agreed to in writing, shall any Contributor be
150
+ liable to You for damages, including any direct, indirect, special,
151
+ incidental, or consequential damages of any character arising as a
152
+ result of this License or out of the use or inability to use the
153
+ Work (including but not limited to damages for loss of goodwill,
154
+ work stoppage, computer failure or malfunction, or any and all
155
+ other commercial damages or losses), even if such Contributor
156
+ has been advised of the possibility of such damages.
157
+
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.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+ APPENDIX: How to apply the Apache License to your work.
170
+
171
+ To apply the Apache License to your work, attach the following
172
+ boilerplate notice, with the fields enclosed by brackets "[]"
173
+ replaced with your own identifying information. (Don't include
174
+ the brackets!) The text should be enclosed in the appropriate
175
+ comment syntax for the file format. We also recommend that a
176
+ 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.
179
+
180
+ Copyright 2023-present deepset GmbH
181
+
182
+ Licensed under the Apache License, Version 2.0 (the "License");
183
+ you may not use this file except in compliance with the License.
184
+ You may obtain a copy of the License at
185
+
186
+ http://www.apache.org/licenses/LICENSE-2.0
187
+
188
+ Unless required by applicable law or agreed to in writing, software
189
+ distributed under the License is distributed on an "AS IS" BASIS,
190
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
191
+ See the License for the specific language governing permissions and
192
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from .chat.chat_generator import CometAPIChatGenerator
6
+
7
+ __all__ = ["CometAPIChatGenerator"]
@@ -0,0 +1,58 @@
1
+ from typing import Any, Dict, List, Optional, Union
2
+
3
+ from haystack.components.generators.chat import OpenAIChatGenerator
4
+ from haystack.dataclasses import StreamingCallbackT
5
+ from haystack.tools import Tool, Toolset
6
+ from haystack.utils import Secret
7
+
8
+
9
+ class CometAPIChatGenerator(OpenAIChatGenerator):
10
+ """
11
+ A chat generator that uses the CometAPI for generating chat responses.
12
+
13
+ This class extends Haystack's OpenAIChatGenerator to specifically interact with the CometAPI.
14
+ It sets the `api_base_url` to the CometAPI endpoint and allows for all the
15
+ standard configurations available in the OpenAIChatGenerator.
16
+
17
+ :param api_key: The API key for authenticating with the CometAPI. Defaults to
18
+ loading from the "COMET_API_KEY" environment variable.
19
+ :param model: The name of the model to use for chat generation (e.g., "gpt-4o-mini", "grok-3-mini").
20
+ Defaults to "gpt-4o-mini".
21
+ :param streaming_callback: An optional callable that will be called with each chunk of
22
+ a streaming response.
23
+ :param generation_kwargs: Optional keyword arguments to pass to the underlying generation
24
+ API call.
25
+ :param timeout: The maximum time in seconds to wait for a response from the API.
26
+ :param max_retries: The maximum number of times to retry a failed API request.
27
+ :param tools: An optional list of tool definitions that the model can use.
28
+ :param tools_strict: If True, the model is forced to use one of the provided tools if a tool call is made.
29
+ :param http_client_kwargs: Optional keyword arguments to pass to the HTTP client.
30
+ """
31
+
32
+ def __init__(
33
+ self,
34
+ *,
35
+ api_key: Secret = Secret.from_env_var("COMET_API_KEY"),
36
+ model: str = "gpt-4o-mini",
37
+ streaming_callback: Optional[StreamingCallbackT] = None,
38
+ generation_kwargs: Optional[Dict[str, Any]] = None,
39
+ timeout: Optional[int] = None,
40
+ max_retries: Optional[int] = None,
41
+ tools: Optional[Union[List[Union[Tool, Toolset]], Toolset]] = None,
42
+ tools_strict: bool = False,
43
+ http_client_kwargs: Optional[Dict[str, Any]] = None,
44
+ ):
45
+ api_base_url = "https://api.cometapi.com/v1"
46
+
47
+ super().__init__(
48
+ api_key=api_key,
49
+ model=model,
50
+ api_base_url=api_base_url,
51
+ streaming_callback=streaming_callback,
52
+ generation_kwargs=generation_kwargs,
53
+ timeout=timeout,
54
+ max_retries=max_retries,
55
+ tools=tools,
56
+ tools_strict=tools_strict,
57
+ http_client_kwargs=http_client_kwargs,
58
+ )
File without changes