aimlapi-haystack 2.1.0__py3-none-any.whl → 3.1.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.
- {aimlapi_haystack-2.1.0.dist-info → aimlapi_haystack-3.1.0.dist-info}/METADATA +5 -5
- {aimlapi_haystack-2.1.0.dist-info → aimlapi_haystack-3.1.0.dist-info}/RECORD +5 -5
- {aimlapi_haystack-2.1.0.dist-info → aimlapi_haystack-3.1.0.dist-info}/WHEEL +1 -1
- haystack_integrations/components/generators/aimlapi/chat/chat_generator.py +7 -60
- {aimlapi_haystack-2.1.0.dist-info → aimlapi_haystack-3.1.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: aimlapi-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/aimlapi#readme
|
|
5
5
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
6
6
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/aimlapi
|
|
@@ -10,15 +10,15 @@ License-File: LICENSE.txt
|
|
|
10
10
|
Classifier: Development Status :: 4 - Beta
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
12
|
Classifier: Programming Language :: Python
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
18
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
19
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
-
Requires-Python: >=3.
|
|
21
|
-
Requires-Dist: haystack-ai>=
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: haystack-ai>=3.5.0
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
24
24
|
# aimlapi-haystack
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
haystack_integrations/components/generators/aimlapi/__init__.py,sha256=QVmh_YP8EKx4gjxrqQ54dzZEZewtjtd1MgsjjJolxpI,90
|
|
3
3
|
haystack_integrations/components/generators/aimlapi/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
haystack_integrations/components/generators/aimlapi/chat/chat_generator.py,sha256=
|
|
5
|
-
aimlapi_haystack-
|
|
6
|
-
aimlapi_haystack-
|
|
7
|
-
aimlapi_haystack-
|
|
8
|
-
aimlapi_haystack-
|
|
4
|
+
haystack_integrations/components/generators/aimlapi/chat/chat_generator.py,sha256=1IxS3_tsB_T3LqyJav1FfSvG4LHK17Art6NQAgfK36k,7447
|
|
5
|
+
aimlapi_haystack-3.1.0.dist-info/METADATA,sha256=_Ykl0ekdPeoVD_Fecdw8h0Oxou2u6A12S5vPFid3E5Y,1880
|
|
6
|
+
aimlapi_haystack-3.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
7
|
+
aimlapi_haystack-3.1.0.dist-info/licenses/LICENSE.txt,sha256=uzzy9ltYNge367fW8mo54Vr-dKlRNoddNEV5nB1ScUM,10273
|
|
8
|
+
aimlapi_haystack-3.1.0.dist-info/RECORD,,
|
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
-
from haystack import component, default_to_dict
|
|
7
|
+
from haystack import component, default_to_dict
|
|
8
8
|
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
9
|
-
from haystack.dataclasses import
|
|
10
|
-
from haystack.tools import ToolsType,
|
|
9
|
+
from haystack.dataclasses import StreamingCallbackT
|
|
10
|
+
from haystack.tools import ToolsType, serialize_tools_or_toolset
|
|
11
11
|
from haystack.utils import serialize_callable
|
|
12
12
|
from haystack.utils.auth import Secret
|
|
13
13
|
|
|
14
|
-
logger = logging.getLogger(__name__)
|
|
15
|
-
|
|
16
14
|
AIMLAPI_HEADERS = {"HTTP-Referer": "https://github.com/deepset-ai/haystack-core-integrations", "X-Title": "Haystack"}
|
|
17
15
|
|
|
18
16
|
|
|
@@ -153,59 +151,8 @@ class AIMLAPIChatGenerator(OpenAIChatGenerator):
|
|
|
153
151
|
http_client_kwargs=self.http_client_kwargs,
|
|
154
152
|
)
|
|
155
153
|
|
|
156
|
-
def
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
streaming_callback: StreamingCallbackT | None = None,
|
|
161
|
-
generation_kwargs: dict[str, Any] | None = None,
|
|
162
|
-
tools: ToolsType | None = None,
|
|
163
|
-
tools_strict: bool | None = None,
|
|
164
|
-
) -> dict[str, Any]:
|
|
165
|
-
# update generation kwargs by merging with the generation kwargs passed to the run method
|
|
166
|
-
generation_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})}
|
|
167
|
-
extra_headers = {**AIMLAPI_HEADERS, **(self.extra_headers or {})}
|
|
168
|
-
|
|
169
|
-
# adapt ChatMessage(s) to the format expected by the OpenAI API (AIMLAPI uses the same format)
|
|
170
|
-
aimlapi_formatted_messages: list[dict[str, Any]] = [message.to_openai_dict_format() for message in messages]
|
|
171
|
-
|
|
172
|
-
tools_strict = tools_strict if tools_strict is not None else self.tools_strict
|
|
173
|
-
flattened_tools = flatten_tools_or_toolsets(tools or self.tools)
|
|
174
|
-
_check_duplicate_tool_names(flattened_tools)
|
|
175
|
-
|
|
176
|
-
openai_tools = {}
|
|
177
|
-
if flattened_tools:
|
|
178
|
-
tool_definitions = []
|
|
179
|
-
for tool in flattened_tools:
|
|
180
|
-
function_spec = {**tool.tool_spec}
|
|
181
|
-
if tools_strict:
|
|
182
|
-
function_spec["strict"] = True
|
|
183
|
-
parameters = function_spec.get("parameters")
|
|
184
|
-
if isinstance(parameters, dict):
|
|
185
|
-
parameters["additionalProperties"] = False
|
|
186
|
-
tool_definitions.append({"type": "function", "function": function_spec})
|
|
187
|
-
openai_tools = {"tools": tool_definitions}
|
|
188
|
-
|
|
189
|
-
is_streaming = streaming_callback is not None
|
|
190
|
-
num_responses = generation_kwargs.pop("n", 1)
|
|
191
|
-
|
|
192
|
-
if is_streaming and num_responses > 1:
|
|
193
|
-
msg = "Cannot stream multiple responses, please set n=1."
|
|
194
|
-
raise ValueError(msg)
|
|
195
|
-
response_format = generation_kwargs.pop("response_format", None)
|
|
196
|
-
|
|
197
|
-
base_args = {
|
|
198
|
-
"model": self.model,
|
|
199
|
-
"messages": aimlapi_formatted_messages,
|
|
200
|
-
"n": num_responses,
|
|
201
|
-
**openai_tools,
|
|
202
|
-
"extra_body": {**generation_kwargs},
|
|
203
|
-
"extra_headers": {**extra_headers},
|
|
154
|
+
def _adapt_generation_kwargs(self, generation_kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
155
|
+
return {
|
|
156
|
+
"extra_body": dict(generation_kwargs),
|
|
157
|
+
"extra_headers": {**AIMLAPI_HEADERS, **(self.extra_headers or {})},
|
|
204
158
|
}
|
|
205
|
-
if response_format and not is_streaming:
|
|
206
|
-
return {**base_args, "response_format": response_format, "openai_endpoint": "parse"}
|
|
207
|
-
|
|
208
|
-
final_args = {**base_args, "stream": is_streaming, "openai_endpoint": "create"}
|
|
209
|
-
if response_format:
|
|
210
|
-
final_args["response_format"] = response_format
|
|
211
|
-
return final_args
|
|
File without changes
|