aimlapi-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.
Files changed (20) hide show
  1. aimlapi_haystack-3.0.0/CHANGELOG.md +70 -0
  2. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/PKG-INFO +4 -4
  3. aimlapi_haystack-3.0.0/examples/aimlapi_with_tools_example.py +54 -0
  4. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/pyproject.toml +3 -2
  5. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/tests/test_aimlapi_chat_generator.py +13 -45
  6. aimlapi_haystack-2.1.0/CHANGELOG.md +0 -29
  7. aimlapi_haystack-2.1.0/examples/aimlapi_with_tools_example.py +0 -77
  8. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/.gitignore +0 -0
  9. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/LICENSE.txt +0 -0
  10. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/README.md +0 -0
  11. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/examples/aimlapi_basic_example.py +0 -0
  12. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/pydoc/config_docusaurus.yml +0 -0
  13. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/src/haystack_integrations/components/generators/aimlapi/__init__.py +0 -0
  14. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/src/haystack_integrations/components/generators/aimlapi/chat/__init__.py +0 -0
  15. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/src/haystack_integrations/components/generators/aimlapi/chat/chat_generator.py +0 -0
  16. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  17. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/tests/__init__.py +0 -0
  18. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/tests/conftest.py +0 -0
  19. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/tests/test_aimlapi_chat_generator_async.py +0 -0
  20. {aimlapi_haystack-2.1.0 → aimlapi_haystack-3.0.0}/tests/test_aimlapi_stub_async.py +0 -0
@@ -0,0 +1,70 @@
1
+ # Changelog
2
+
3
+ ## [integrations/aimlapi-v2.1.0] - 2026-07-13
4
+
5
+ ### 🚀 Features
6
+
7
+ - Improve type annotations, fix duplicate code in aimlapi integration (#2969)
8
+
9
+ ### 🐛 Bug Fixes
10
+
11
+ - Support Haystack 3.0's lazy OpenAI client initialization in OpenAI-inheriting generators (#3536)
12
+
13
+ ### 📚 Documentation
14
+
15
+ - Simplify pydoc configs (#2855)
16
+
17
+ ### 🧪 Testing
18
+
19
+ - Relax AIMLAPI tests (#2815)
20
+ - Test compatible integrations with python 3.14; update pyproject (#3001)
21
+ - Track test coverage for all integrations (#3065)
22
+ - Aimlapi - add unit tests (#3184)
23
+ - Trust test modules under Haystack 3.0's deserialization allowlist (#3537)
24
+ - Make Tool/Agent serialization assertions version-agnostic for Haystack 2.x/3.x (#3533)
25
+ - Guard ToolInvoker imports so chat-generator tests run under Haystack 3.0 (#3535)
26
+ - Fix tests for integrations that inherit from the OpenAIChatGenerator (#3583)
27
+
28
+ ### 🧹 Chores
29
+
30
+ - Standardize author mentions (#2897)
31
+ - Enforce ruff docstring rules (D102/D103/D205/D209/D213/D417/D419) in first 10 integrations (#3008)
32
+ - Update aimlapi (#3290)
33
+
34
+
35
+ ## [integrations/aimlapi-v2.0.0] - 2026-01-09
36
+
37
+
38
+ ### 🧹 Chores
39
+
40
+ - Remove Readme API CI workflow and configs (#2573)
41
+ - Make fmt command more forgiving (#2671)
42
+ - [**breaking**] Aimlapi - drop Python 3.9 and use X|Y typing (#2684)
43
+
44
+ ### 🌀 Miscellaneous
45
+
46
+ - Enhancement: Adopt PEP 585 type hinting (part 6) (#2532)
47
+
48
+ ## [integrations/aimlapi-v1.0.0] - 2025-11-12
49
+
50
+ ### 🚀 Features
51
+
52
+ - *(aimlapi)* Add AIMLAPI provider integration (#2267)
53
+
54
+ ### 📚 Documentation
55
+
56
+ - Add pydoc configurations for Docusaurus (#2411)
57
+
58
+ ### ⚙️ CI
59
+
60
+ - Change pytest command (#2475)
61
+
62
+ ### 🧹 Chores
63
+
64
+ - AIMLAPI - clean up README (#2356)
65
+
66
+ ### 🌀 Miscellaneous
67
+
68
+ - Add missing GA workflow for `aimlapi` integration (#2504)
69
+
70
+ <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: aimlapi-haystack
3
- Version: 2.1.0
3
+ Version: 3.0.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,14 +10,14 @@ 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.10
20
+ Requires-Python: >=3.11
21
21
  Requires-Dist: haystack-ai>=2.22.0
22
22
  Description-Content-Type: text/markdown
23
23
 
@@ -0,0 +1,54 @@
1
+ # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ # ruff: noqa: T201
6
+
7
+ """Run AIMLAPI chat generation with tool calling and execution."""
8
+
9
+ from haystack.components.agents import Agent
10
+ from haystack.dataclasses import ChatMessage
11
+ from haystack.tools import Tool
12
+
13
+ from haystack_integrations.components.generators.aimlapi import AIMLAPIChatGenerator
14
+
15
+
16
+ def weather(city: str) -> str:
17
+ """Return mock weather info for the given city."""
18
+
19
+ return f"The weather in {city} is sunny and 32°C"
20
+
21
+
22
+ def main() -> None:
23
+ """Demonstrate an Agent calling a tool and feeding the result back to AIMLAPI."""
24
+
25
+ tool_parameters = {
26
+ "type": "object",
27
+ "properties": {"city": {"type": "string"}},
28
+ "required": ["city"],
29
+ }
30
+
31
+ weather_tool = Tool(
32
+ name="weather",
33
+ description="Useful for getting the weather in a specific city",
34
+ parameters=tool_parameters,
35
+ function=weather,
36
+ )
37
+
38
+ agent = Agent(
39
+ chat_generator=AIMLAPIChatGenerator(model="openai/gpt-5-mini-2025-08-07"),
40
+ system_prompt="You help users by calling the provided tools when they are relevant.",
41
+ tools=[weather_tool],
42
+ )
43
+
44
+ result = agent.run(messages=[ChatMessage.from_user("What's the weather in Tokyo today?")])
45
+
46
+ for message in result["messages"]:
47
+ if message.tool_call_result:
48
+ print(f"tool output: {message.tool_call_result.result}")
49
+
50
+ print(f"assistant final answer: {result['last_message'].text}")
51
+
52
+
53
+ if __name__ == "__main__":
54
+ main()
@@ -7,7 +7,7 @@ name = "aimlapi-haystack"
7
7
  dynamic = ["version"]
8
8
  description = ''
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = "Apache-2.0"
12
12
  keywords = []
13
13
  authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }, { name = "Dmitry <D1m7asis> Tumanov", email = "d1m7asis@gmail.com" }]
@@ -15,11 +15,11 @@ classifiers = [
15
15
  "License :: OSI Approved :: Apache Software License",
16
16
  "Development Status :: 4 - Beta",
17
17
  "Programming Language :: Python",
18
- "Programming Language :: Python :: 3.10",
19
18
  "Programming Language :: Python :: 3.11",
20
19
  "Programming Language :: Python :: 3.12",
21
20
  "Programming Language :: Python :: 3.13",
22
21
  "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: 3.15",
23
23
  "Programming Language :: Python :: Implementation :: CPython",
24
24
  "Programming Language :: Python :: Implementation :: PyPy",
25
25
  ]
@@ -127,6 +127,7 @@ ignore = [
127
127
  "PLR0912",
128
128
  "PLR0913",
129
129
  "PLR0915",
130
+ "PLR0917",
130
131
  # Misc
131
132
  "B008",
132
133
  "S101",
@@ -5,12 +5,8 @@ from unittest.mock import patch
5
5
  import pytest
6
6
  import pytz
7
7
  from haystack import Pipeline
8
+ from haystack.components.agents import Agent
8
9
  from haystack.components.generators.utils import print_streaming_chunk
9
-
10
- try:
11
- from haystack.components.tools import ToolInvoker
12
- except ImportError: # ToolInvoker was removed in Haystack 3.0
13
- ToolInvoker = None
14
10
  from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk, ToolCall
15
11
  from haystack.tools import Tool
16
12
  from haystack.utils.auth import Secret
@@ -409,30 +405,15 @@ class TestAIMLAPIChatGenerator:
409
405
  reason="Export an env var called AIMLAPI_API_KEY containing the AIMLAPI API key to run this test.",
410
406
  )
411
407
  @pytest.mark.integration
412
- @pytest.mark.skipif(ToolInvoker is None, reason="ToolInvoker is not available in the installed haystack-ai version")
413
- def test_pipeline_with_aimlapi_chat_generator(self, tools):
408
+ def test_agent_with_aimlapi_chat_generator(self, tools):
414
409
  """
415
- Test that the AIMLAPIChatGenerator component can be used in a pipeline
410
+ Test that the AIMLAPIChatGenerator component can drive tool calls in an Agent
416
411
  """
417
- pipeline = Pipeline()
418
- pipeline.add_component("generator", AIMLAPIChatGenerator(tools=tools, model="openai/gpt-5-mini-2025-08-07"))
419
- pipeline.add_component("tool_invoker", ToolInvoker(tools=tools))
412
+ agent = Agent(chat_generator=AIMLAPIChatGenerator(model="openai/gpt-5-mini-2025-08-07"), tools=tools)
413
+ result = agent.run(messages=[ChatMessage.from_user("What's the weather like in Paris?")])
420
414
 
421
- pipeline.connect("generator", "tool_invoker")
422
-
423
- results = pipeline.run(
424
- data={
425
- "generator": {
426
- "messages": [ChatMessage.from_user("What's the weather like in Paris?")],
427
- "generation_kwargs": {"tool_choice": "auto"},
428
- }
429
- }
430
- )
431
-
432
- assert (
433
- "The weather in Paris is sunny and 32°C"
434
- == results["tool_invoker"]["tool_messages"][0].tool_call_result.result
435
- )
415
+ tool_results = [msg.tool_call_result.result for msg in result["messages"] if msg.tool_call_result]
416
+ assert "The weather in Paris is sunny and 32°C" in tool_results
436
417
 
437
418
  def test_serde_in_pipeline(self, monkeypatch):
438
419
  """
@@ -901,22 +882,9 @@ class TestChatCompletionChunkConversion:
901
882
  assert result.meta["index"] == 0
902
883
  assert result.meta["completion_start_time"] is not None
903
884
 
904
- # Normalize usage details since cache_write_tokens is not always present in the response
905
- result.meta["usage"]["prompt_tokens_details"].setdefault("cache_write_tokens", None)
906
-
907
- assert result.meta["usage"] == {
908
- "completion_tokens": 42,
909
- "prompt_tokens": 55,
910
- "total_tokens": 97,
911
- "completion_tokens_details": {
912
- "accepted_prediction_tokens": None,
913
- "audio_tokens": None,
914
- "reasoning_tokens": 0,
915
- "rejected_prediction_tokens": None,
916
- },
917
- "prompt_tokens_details": {
918
- "audio_tokens": None,
919
- "cache_write_tokens": None,
920
- "cached_tokens": 0,
921
- },
922
- }
885
+ usage = result.meta["usage"]
886
+ assert usage["completion_tokens"] == 42
887
+ assert usage["prompt_tokens"] == 55
888
+ assert usage["total_tokens"] == 97
889
+ assert usage["completion_tokens_details"]["reasoning_tokens"] == 0
890
+ assert usage["prompt_tokens_details"]["cached_tokens"] == 0
@@ -1,29 +0,0 @@
1
- # Changelog
2
-
3
- ## [integrations/aimlapi-v2.0.0] - 2026-01-09
4
-
5
- ### 🚀 Features
6
-
7
- - *(aimlapi)* Add AIMLAPI provider integration (#2267)
8
-
9
- ### 📚 Documentation
10
-
11
- - Add pydoc configurations for Docusaurus (#2411)
12
-
13
- ### ⚙️ CI
14
-
15
- - Change pytest command (#2475)
16
-
17
- ### 🧹 Chores
18
-
19
- - AIMLAPI - clean up README (#2356)
20
- - Remove Readme API CI workflow and configs (#2573)
21
- - Make fmt command more forgiving (#2671)
22
- - [**breaking**] Aimlapi - drop Python 3.9 and use X|Y typing (#2684)
23
-
24
- ### 🌀 Miscellaneous
25
-
26
- - Add missing GA workflow for `aimlapi` integration (#2504)
27
- - Enhancement: Adopt PEP 585 type hinting (part 6) (#2532)
28
-
29
- <!-- generated by git-cliff -->
@@ -1,77 +0,0 @@
1
- # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- # ruff: noqa: T201
6
-
7
- """Run AIMLAPI chat generation with tool calling and execution."""
8
-
9
- from haystack.components.tools import ToolInvoker
10
- from haystack.dataclasses import ChatMessage
11
- from haystack.tools import Tool
12
-
13
- from haystack_integrations.components.generators.aimlapi import AIMLAPIChatGenerator
14
-
15
-
16
- def weather(city: str) -> str:
17
- """Return mock weather info for the given city."""
18
-
19
- return f"The weather in {city} is sunny and 32°C"
20
-
21
-
22
- def main() -> None:
23
- """Demonstrate calling a tool and feeding the result back to AIMLAPI."""
24
-
25
- tool_parameters = {
26
- "type": "object",
27
- "properties": {"city": {"type": "string"}},
28
- "required": ["city"],
29
- }
30
-
31
- weather_tool = Tool(
32
- name="weather",
33
- description="Useful for getting the weather in a specific city",
34
- parameters=tool_parameters,
35
- function=weather,
36
- )
37
-
38
- tool_invoker = ToolInvoker(tools=[weather_tool])
39
-
40
- client = AIMLAPIChatGenerator(model="openai/gpt-5-mini-2025-08-07")
41
-
42
- messages = [
43
- ChatMessage.from_system("You help users by calling the provided tools when they are relevant."),
44
- ChatMessage.from_user("What's the weather in Tokyo today?"),
45
- ]
46
-
47
- print("Requesting a tool call from the model...")
48
- tool_request = client.run(
49
- messages=messages,
50
- tools=[weather_tool],
51
- generation_kwargs={"tool_choice": {"type": "function", "function": {"name": "weather"}}},
52
- )["replies"][0]
53
-
54
- print(f"assistant tool request: {tool_request}")
55
-
56
- if not tool_request.tool_calls:
57
- print("No tool call was produced by the model.")
58
- return
59
-
60
- tool_messages = tool_invoker.run(messages=[tool_request])["tool_messages"]
61
- for tool_message in tool_messages:
62
- for tool_result in tool_message.tool_call_results:
63
- print(f"tool output: {tool_result.result}")
64
-
65
- follow_up_messages = [*messages, tool_request, *tool_messages]
66
-
67
- final_reply = client.run(
68
- messages=follow_up_messages,
69
- tools=[weather_tool],
70
- generation_kwargs={"tool_choice": "none"},
71
- )["replies"][0]
72
-
73
- print(f"assistant final answer: {final_reply.text}")
74
-
75
-
76
- if __name__ == "__main__":
77
- main()