cometapi-haystack 3.0.0__py3-none-any.whl → 4.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.
- {cometapi_haystack-3.0.0.dist-info → cometapi_haystack-4.0.0.dist-info}/METADATA +1 -1
- cometapi_haystack-4.0.0.dist-info/RECORD +7 -0
- {cometapi_haystack-3.0.0.dist-info → cometapi_haystack-4.0.0.dist-info}/WHEEL +1 -1
- haystack_integrations/components/generators/cometapi/chat/chat_generator.py +31 -2
- cometapi_haystack-3.0.0.dist-info/RECORD +0 -7
- {cometapi_haystack-3.0.0.dist-info → cometapi_haystack-4.0.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cometapi-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.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
|
|
@@ -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=jaJAPB2B5oH41W-IJ3A271CucvwYDsoliZGnpUiheWw,5186
|
|
4
|
+
cometapi_haystack-4.0.0.dist-info/METADATA,sha256=0VApLOzJmfA4_BMq53xPKje3NdlO_sPLSsroMXIazBw,1963
|
|
5
|
+
cometapi_haystack-4.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
6
|
+
cometapi_haystack-4.0.0.dist-info/licenses/LICENSE.txt,sha256=OrAtTu4aPmrTjKDSTzkSPgo_ji6NOMWO2N9JOTFyAzM,11350
|
|
7
|
+
cometapi_haystack-4.0.0.dist-info/RECORD,,
|
|
@@ -3,15 +3,22 @@ from typing import Any
|
|
|
3
3
|
from haystack import component, default_to_dict
|
|
4
4
|
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
5
5
|
from haystack.dataclasses import (
|
|
6
|
+
ChatMessage,
|
|
6
7
|
StreamingCallbackT,
|
|
7
8
|
)
|
|
8
9
|
from haystack.tools import (
|
|
9
10
|
Tool,
|
|
10
11
|
Toolset,
|
|
12
|
+
ToolsType,
|
|
11
13
|
serialize_tools_or_toolset,
|
|
12
14
|
)
|
|
13
15
|
from haystack.utils import Secret, serialize_callable
|
|
14
16
|
|
|
17
|
+
# These models accept function tools over Chat Completions only with `reasoning_effort="none"` and return HTTP 400
|
|
18
|
+
# otherwise. Haystack's OpenAIChatGenerator applies this default for its own list of models, which doesn't include
|
|
19
|
+
# these yet; remove this once it does.
|
|
20
|
+
_NO_REASONING_TOOL_CALL_MODEL_PREFIXES = ("gpt-6.1-terra",)
|
|
21
|
+
|
|
15
22
|
|
|
16
23
|
@component
|
|
17
24
|
class CometAPIChatGenerator(OpenAIChatGenerator):
|
|
@@ -27,7 +34,7 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
|
|
|
27
34
|
self,
|
|
28
35
|
*,
|
|
29
36
|
api_key: Secret = Secret.from_env_var("COMET_API_KEY"),
|
|
30
|
-
model: str = "gpt-
|
|
37
|
+
model: str = "gpt-6.1-terra",
|
|
31
38
|
streaming_callback: StreamingCallbackT | None = None,
|
|
32
39
|
generation_kwargs: dict[str, Any] | None = None,
|
|
33
40
|
timeout: int | None = None,
|
|
@@ -40,7 +47,7 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
|
|
|
40
47
|
Creates a `CometAPIChatGenerator` instance.
|
|
41
48
|
|
|
42
49
|
: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-
|
|
50
|
+
:param model: The name of the model to use for chat generation (e.g., `"gpt-6.1-terra"`, `"grok-3-mini"`).
|
|
44
51
|
:param streaming_callback: An optional callable invoked with each chunk of a streaming response.
|
|
45
52
|
:param generation_kwargs: Optional keyword arguments passed to the underlying generation API call.
|
|
46
53
|
:param timeout: The maximum time in seconds to wait for a response from the API.
|
|
@@ -65,6 +72,28 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
|
|
|
65
72
|
http_client_kwargs=http_client_kwargs,
|
|
66
73
|
)
|
|
67
74
|
|
|
75
|
+
def _prepare_api_call(
|
|
76
|
+
self,
|
|
77
|
+
*,
|
|
78
|
+
messages: list[ChatMessage],
|
|
79
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
80
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
81
|
+
tools: ToolsType | None = None,
|
|
82
|
+
tools_strict: bool | None = None,
|
|
83
|
+
) -> dict[str, Any]:
|
|
84
|
+
# the @component decorator recreates the class, so the zero-argument form of super() cannot be used
|
|
85
|
+
api_args = super(CometAPIChatGenerator, self)._prepare_api_call( # noqa: UP008
|
|
86
|
+
messages=messages,
|
|
87
|
+
streaming_callback=streaming_callback,
|
|
88
|
+
generation_kwargs=generation_kwargs,
|
|
89
|
+
tools=tools,
|
|
90
|
+
tools_strict=tools_strict,
|
|
91
|
+
)
|
|
92
|
+
# setdefault keeps a reasoning_effort the user set explicitly
|
|
93
|
+
if "tools" in api_args and self.model.startswith(_NO_REASONING_TOOL_CALL_MODEL_PREFIXES):
|
|
94
|
+
api_args.setdefault("reasoning_effort", "none")
|
|
95
|
+
return api_args
|
|
96
|
+
|
|
68
97
|
def to_dict(self) -> dict[str, Any]:
|
|
69
98
|
"""
|
|
70
99
|
Serialize this component to a dictionary.
|
|
@@ -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=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,,
|
{cometapi_haystack-3.0.0.dist-info → cometapi_haystack-4.0.0.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|