watsonx-haystack 1.5.0__tar.gz → 1.7.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 (25) hide show
  1. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/CHANGELOG.md +29 -0
  2. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/PKG-INFO +4 -4
  3. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/pyproject.toml +4 -3
  4. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/embedders/watsonx/document_embedder.py +1 -1
  5. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/embedders/watsonx/text_embedder.py +1 -1
  6. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/generators/watsonx/chat/chat_generator.py +7 -4
  7. watsonx_haystack-1.7.0/tests/conftest.py +11 -0
  8. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/tests/test_chat_generator.py +19 -42
  9. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/.gitignore +0 -0
  10. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/LICENSE.txt +0 -0
  11. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/README.md +0 -0
  12. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/examples/chat_generator_example.py +0 -0
  13. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/examples/embedders_example.py +0 -0
  14. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/pydoc/config_docusaurus.yml +0 -0
  15. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
  16. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/embedders/watsonx/__init__.py +0 -0
  17. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  18. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/generators/watsonx/__init__.py +0 -0
  19. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/generators/watsonx/chat/__init__.py +0 -0
  20. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/src/haystack_integrations/components/generators/watsonx/generator.py +0 -0
  21. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/tests/__init__.py +0 -0
  22. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/tests/test_document_embedder.py +0 -0
  23. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/tests/test_files/apple.jpg +0 -0
  24. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/tests/test_generator.py +0 -0
  25. {watsonx_haystack-1.5.0 → watsonx_haystack-1.7.0}/tests/test_text_embedder.py +0 -0
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [unreleased]
4
+
5
+ ### 🧪 Testing
6
+
7
+ - Fix failing test watsonx integration (#3414)
8
+ - Trust test modules under Haystack 3.0's deserialization allowlist (#3537)
9
+ - Make Tool/Agent serialization assertions version-agnostic for Haystack 2.x/3.x (#3533)
10
+
11
+ ### 🧹 Chores
12
+
13
+ - Support sync streaming callbacks in async contexts for Haystack 2.x/3.x compatibility (#3534)
14
+
15
+
16
+ ## [integrations/watsonx-v1.5.0] - 2026-06-04
17
+
18
+ ### 🚀 Features
19
+
20
+ - Watsonx - accept str as ChatGenerator input; deprecate generator; rm generator example (#3396)
21
+
22
+ ### 🧪 Testing
23
+
24
+ - Track test coverage for all integrations (#3065)
25
+
26
+ ### 🧹 Chores
27
+
28
+ - Add ANN type annotations to stackit, togetherai, unstructured, valkey, watsonx, weave, weaviate (#2994)
29
+ - Enforce ruff docstring rules (D102/D103/D205/D209/D213/D417/D419) in integrations 41-47 (#3012)
30
+
31
+
3
32
  ## [integrations/watsonx-v1.4.0] - 2026-03-13
4
33
 
5
34
  ### 🚀 Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: watsonx-haystack
3
- Version: 1.5.0
3
+ Version: 1.7.0
4
4
  Summary: Watsonx integration for Haystack
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/watsonx#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -11,13 +11,13 @@ 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
18
- Requires-Python: >=3.10
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Requires-Python: >=3.11
19
19
  Requires-Dist: haystack-ai>=2.30.0
20
- Requires-Dist: ibm-watsonx-ai>=1.3.26
20
+ Requires-Dist: ibm-watsonx-ai>=1.5.13
21
21
  Requires-Dist: pandas>=2.2.3
22
22
  Description-Content-Type: text/markdown
23
23
 
@@ -7,7 +7,7 @@ name = "watsonx-haystack"
7
7
  dynamic = ["version"]
8
8
  description = "Watsonx integration for Haystack"
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = "Apache-2.0"
12
12
  authors = [
13
13
  { name = "Divya", email = "divyaruhil999@gmail.com" },
@@ -17,12 +17,12 @@ classifiers = [
17
17
  "License :: OSI Approved :: Apache Software License",
18
18
  "Development Status :: 4 - Beta",
19
19
  "Programming Language :: Python",
20
- "Programming Language :: Python :: 3.10",
21
20
  "Programming Language :: Python :: 3.11",
22
21
  "Programming Language :: Python :: 3.12",
23
22
  "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
24
  ]
25
- dependencies = ["haystack-ai>=2.30.0", "ibm-watsonx-ai>=1.3.26", "pandas>=2.2.3"]
25
+ dependencies = ["haystack-ai>=2.30.0", "ibm-watsonx-ai>=1.5.13", "pandas>=2.2.3"]
26
26
 
27
27
  [project.urls]
28
28
  Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/watsonx#readme"
@@ -137,6 +137,7 @@ ignore = [
137
137
  "PLR0912",
138
138
  "PLR0913",
139
139
  "PLR0915",
140
+ "PLR0917",
140
141
  # Ignore unused params
141
142
  "ARG001",
142
143
  "ARG002",
@@ -116,7 +116,7 @@ class WatsonxDocumentEmbedder:
116
116
  model_id=model,
117
117
  credentials=credentials,
118
118
  project_id=project_id.resolve_value(),
119
- params=params if params else None,
119
+ params=params if params else None, # type: ignore[arg-type]
120
120
  batch_size=batch_size,
121
121
  concurrency_limit=concurrency_limit,
122
122
  max_retries=max_retries,
@@ -100,7 +100,7 @@ class WatsonxTextEmbedder:
100
100
  model_id=model,
101
101
  credentials=credentials,
102
102
  project_id=project_id.resolve_value(),
103
- params=params if params else None,
103
+ params=params if params else None, # type: ignore[arg-type]
104
104
  max_retries=max_retries,
105
105
  )
106
106
 
@@ -2,6 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
+ import inspect
5
6
  import json
6
7
  from dataclasses import replace
7
8
  from datetime import datetime, timezone
@@ -10,7 +11,6 @@ from typing import Any, ClassVar, Literal, get_args
10
11
  from haystack import component, default_from_dict, default_to_dict, logging
11
12
  from haystack.components.generators.utils import _convert_streaming_chunks_to_chat_message, _normalize_messages
12
13
  from haystack.dataclasses import (
13
- AsyncStreamingCallbackT,
14
14
  ChatMessage,
15
15
  ChatRole,
16
16
  ComponentInfo,
@@ -352,7 +352,7 @@ class WatsonxChatGenerator:
352
352
  merged_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})}
353
353
 
354
354
  watsonx_messages = []
355
- content: str | None | dict[str, Any] | list[dict[str, Any]]
355
+ content: str | dict[str, Any] | list[dict[str, Any]] | None
356
356
 
357
357
  flattened_tools = flatten_tools_or_toolsets(tools or self.tools)
358
358
  _check_duplicate_tool_names(flattened_tools)
@@ -510,7 +510,7 @@ class WatsonxChatGenerator:
510
510
  self,
511
511
  *,
512
512
  api_args: dict[str, Any],
513
- callback: AsyncStreamingCallbackT,
513
+ callback: StreamingCallbackT,
514
514
  ) -> dict[str, list[ChatMessage]]:
515
515
  """Handle asynchronous streaming response."""
516
516
  chunks: list[StreamingChunk] = []
@@ -525,7 +525,10 @@ class WatsonxChatGenerator:
525
525
 
526
526
  streaming_chunk = self._convert_chunk_to_streaming_chunk(chunk, component_info)
527
527
  chunks.append(streaming_chunk)
528
- await callback(streaming_chunk)
528
+ # sync callbacks are allowed in async contexts with Haystack >= 3.0, so only await async ones
529
+ callback_result = callback(streaming_chunk)
530
+ if inspect.isawaitable(callback_result):
531
+ await callback_result
529
532
 
530
533
  chat_message = _convert_streaming_chunks_to_chat_message(chunks)
531
534
  message_tool_calls = [
@@ -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_*")
@@ -206,6 +206,11 @@ class TestWatsonxChatGenerator:
206
206
 
207
207
  data = generator.to_dict()
208
208
 
209
+ # the Tool serialization format is owned by haystack-ai and varies across its versions; the
210
+ # from_dict round-trip below covers the tools, so exclude them from the pinned-dict comparison
211
+ tools_entries = data["init_parameters"].pop("tools")
212
+ assert len(tools_entries) == len(tools)
213
+
209
214
  expected = {
210
215
  "type": "haystack_integrations.components.generators.watsonx.chat.chat_generator.WatsonxChatGenerator",
211
216
  "init_parameters": {
@@ -218,28 +223,14 @@ class TestWatsonxChatGenerator:
218
223
  "timeout": None,
219
224
  "max_retries": None,
220
225
  "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
221
- "tools": [
222
- {
223
- "data": {
224
- "description": "useful to determine the weather in a given location",
225
- "function": "tests.test_chat_generator.weather",
226
- "inputs_from_state": None,
227
- "name": "weather",
228
- "outputs_to_state": None,
229
- "outputs_to_string": None,
230
- "parameters": {
231
- "properties": {"city": {"type": "string"}},
232
- "required": ["city"],
233
- "type": "object",
234
- },
235
- },
236
- "type": "haystack.tools.tool.Tool",
237
- },
238
- ],
239
226
  },
240
227
  }
241
228
  assert data == expected
242
229
 
230
+ # deserializing the serialized component must reproduce the original tools
231
+ loaded = WatsonxChatGenerator.from_dict(generator.to_dict())
232
+ assert loaded.tools == tools
233
+
243
234
  def test_from_dict(self, mock_watsonx):
244
235
  assert mock_watsonx is not None
245
236
  data = {
@@ -917,11 +908,8 @@ class TestWatsonxChatGeneratorIntegration:
917
908
  # Mix standalone tool with toolset
918
909
  mixed_tools = [weather_tool, population_toolset]
919
910
 
920
- initial_messages = [
921
- ChatMessage.from_user("What's the weather like in Paris and what is the population of Berlin?")
922
- ]
911
+ initial_messages = [ChatMessage.from_user("What's the weather like in Paris?")]
923
912
  component = WatsonxChatGenerator(
924
- model="meta-llama/llama-3-2-11b-vision-instruct",
925
913
  project_id=Secret.from_env_var("WATSONX_PROJECT_ID"),
926
914
  tools=mixed_tools,
927
915
  )
@@ -935,28 +923,18 @@ class TestWatsonxChatGeneratorIntegration:
935
923
  assert first_reply.tool_calls, "First reply has no tool calls"
936
924
 
937
925
  tool_calls = first_reply.tool_calls
938
- assert len(tool_calls) == 2, f"Expected 2 tool calls, got {len(tool_calls)}"
939
-
940
- # Verify we got calls to both weather and population tools
941
- tool_names = {tc.tool_name for tc in tool_calls}
942
- assert "weather" in tool_names, "Expected 'weather' tool call"
943
- assert "population" in tool_names, "Expected 'population' tool call"
926
+ assert len(tool_calls) == 1, f"Expected 1 tool calls, got {len(tool_calls)}"
944
927
 
945
928
  # Verify tool call details
946
- for tool_call in tool_calls:
947
- assert tool_call.tool_name in ["weather", "population"]
948
- assert "city" in tool_call.arguments
949
- assert tool_call.arguments["city"] in ["Paris", "Berlin"]
950
- assert first_reply.meta["finish_reason"] == "tool_calls"
929
+ assert tool_calls[0].tool_name == "weather"
930
+ assert "city" in tool_calls[0].arguments
931
+ assert tool_calls[0].arguments["city"].lower() == "paris"
932
+ assert first_reply.meta["finish_reason"] == "tool_calls"
951
933
 
952
934
  # Mock the response we'd get from ToolInvoker
953
- tool_result_messages = []
954
- for tool_call in tool_calls:
955
- if tool_call.tool_name == "weather":
956
- result = "The weather in Paris is sunny and 32°C"
957
- else: # population
958
- result = "The population of Berlin is 2.2 million"
959
- tool_result_messages.append(ChatMessage.from_tool(tool_result=result, origin=tool_call))
935
+ tool_result_messages = [
936
+ ChatMessage.from_tool(tool_result="The weather in Paris is sunny and 32°C", origin=tool_calls[0])
937
+ ]
960
938
 
961
939
  new_messages = [*initial_messages, first_reply, *tool_result_messages]
962
940
  results = component.run(messages=new_messages)
@@ -966,7 +944,6 @@ class TestWatsonxChatGeneratorIntegration:
966
944
  assert not final_message.tool_calls
967
945
  assert len(final_message.text) > 0
968
946
  assert "paris" in final_message.text.lower()
969
- assert "berlin" in final_message.text.lower()
970
947
 
971
948
  @pytest.mark.asyncio
972
949
  @pytest.mark.skipif(
@@ -1017,7 +994,7 @@ class TestWatsonxChatGeneratorIntegration:
1017
994
  )
1018
995
  def test_live_run_multimodal(self):
1019
996
  generator = WatsonxChatGenerator(
1020
- model="meta-llama/llama-3-2-11b-vision-instruct",
997
+ model="meta-llama/llama-4-maverick-17b-128e-instruct-fp8",
1021
998
  project_id=Secret.from_env_var("WATSONX_PROJECT_ID"),
1022
999
  )
1023
1000