watsonx-haystack 1.6.0__tar.gz → 2.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 (26) hide show
  1. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/CHANGELOG.md +24 -0
  2. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/LICENSE.txt +1 -1
  3. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/PKG-INFO +6 -6
  4. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/pydoc/config_docusaurus.yml +0 -1
  5. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/pyproject.toml +4 -3
  6. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/src/haystack_integrations/components/embedders/watsonx/document_embedder.py +18 -10
  7. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/src/haystack_integrations/components/embedders/watsonx/text_embedder.py +16 -8
  8. watsonx_haystack-2.0.0/src/haystack_integrations/components/generators/watsonx/chat/__init__.py +6 -0
  9. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/src/haystack_integrations/components/generators/watsonx/chat/chat_generator.py +23 -9
  10. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/tests/test_chat_generator.py +184 -164
  11. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/tests/test_document_embedder.py +82 -88
  12. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/tests/test_text_embedder.py +64 -77
  13. watsonx_haystack-1.6.0/src/haystack_integrations/components/generators/watsonx/__init__.py +0 -6
  14. watsonx_haystack-1.6.0/src/haystack_integrations/components/generators/watsonx/generator.py +0 -294
  15. watsonx_haystack-1.6.0/tests/test_generator.py +0 -433
  16. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/.gitignore +0 -0
  17. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/README.md +0 -0
  18. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/examples/chat_generator_example.py +0 -0
  19. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/examples/embedders_example.py +0 -0
  20. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
  21. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/src/haystack_integrations/components/embedders/watsonx/__init__.py +0 -0
  22. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  23. {watsonx_haystack-1.6.0/src/haystack_integrations/components/generators/watsonx/chat → watsonx_haystack-2.0.0/src/haystack_integrations/components/generators/watsonx}/__init__.py +0 -0
  24. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/tests/__init__.py +0 -0
  25. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/tests/conftest.py +0 -0
  26. {watsonx_haystack-1.6.0 → watsonx_haystack-2.0.0}/tests/test_files/apple.jpg +0 -0
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/watsonx-v1.7.0] - 2026-08-07
4
+
5
+ ### 🚀 Features
6
+
7
+ - Add Python 3.14 support for WatsonX integration (#3744)
8
+
9
+ ### 🐛 Bug Fixes
10
+
11
+ - Fix new issues raised by ruff 0.16.0 (#3670)
12
+
13
+
14
+ ## [integrations/watsonx-v1.6.0] - 2026-07-09
15
+
16
+ ### 🧪 Testing
17
+
18
+ - Fix failing test watsonx integration (#3414)
19
+ - Trust test modules under Haystack 3.0's deserialization allowlist (#3537)
20
+ - Make Tool/Agent serialization assertions version-agnostic for Haystack 2.x/3.x (#3533)
21
+
22
+ ### 🧹 Chores
23
+
24
+ - Support sync streaming callbacks in async contexts for Haystack 2.x/3.x compatibility (#3534)
25
+
26
+
3
27
  ## [integrations/watsonx-v1.5.0] - 2026-06-04
4
28
 
5
29
  ### 🚀 Features
@@ -58,7 +58,7 @@ APPENDIX: How to apply the Apache License to your work.
58
58
 
59
59
  To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
60
 
61
- Copyright [yyyy] [name of copyright owner]
61
+ Copyright 2023-present deepset GmbH
62
62
 
63
63
  Licensed under the Apache License, Version 2.0 (the "License");
64
64
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: watsonx-haystack
3
- Version: 1.6.0
3
+ Version: 2.0.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
19
- Requires-Dist: haystack-ai>=2.30.0
20
- Requires-Dist: ibm-watsonx-ai>=1.3.26
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: haystack-ai>=3.0.0
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
 
@@ -1,6 +1,5 @@
1
1
  loaders:
2
2
  - modules:
3
- - haystack_integrations.components.generators.watsonx.generator
4
3
  - haystack_integrations.components.generators.watsonx.chat.chat_generator
5
4
  - haystack_integrations.components.embedders.watsonx.document_embedder
6
5
  - haystack_integrations.components.embedders.watsonx.text_embedder
@@ -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>=3.0.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",
@@ -105,21 +105,27 @@ class WatsonxDocumentEmbedder:
105
105
  self.meta_fields_to_embed = meta_fields_to_embed or []
106
106
  self.embedding_separator = embedding_separator
107
107
 
108
- # Initialize the embeddings client
109
- credentials = Credentials(api_key=api_key.resolve_value(), url=api_base_url)
108
+ self.embedder: Embeddings | None = None
109
+
110
+ def warm_up(self) -> None:
111
+ """Create the Watsonx embeddings client."""
112
+ if self.embedder is not None:
113
+ return
114
+
115
+ credentials = Credentials(api_key=self.api_key.resolve_value(), url=self.api_base_url)
110
116
 
111
117
  params = {}
112
- if truncate_input_tokens is not None:
113
- params["truncate_input_tokens"] = truncate_input_tokens
118
+ if self.truncate_input_tokens is not None:
119
+ params["truncate_input_tokens"] = self.truncate_input_tokens
114
120
 
115
121
  self.embedder = Embeddings(
116
- model_id=model,
122
+ model_id=self.model,
117
123
  credentials=credentials,
118
- project_id=project_id.resolve_value(),
119
- params=params if params else None,
120
- batch_size=batch_size,
121
- concurrency_limit=concurrency_limit,
122
- max_retries=max_retries,
124
+ project_id=self.project_id.resolve_value(),
125
+ params=params if params else None, # type: ignore[arg-type]
126
+ batch_size=self.batch_size,
127
+ concurrency_limit=self.concurrency_limit,
128
+ max_retries=self.max_retries,
123
129
  )
124
130
 
125
131
  def _get_telemetry_data(self) -> dict[str, Any]:
@@ -203,6 +209,8 @@ class WatsonxDocumentEmbedder:
203
209
  raise TypeError(msg)
204
210
 
205
211
  texts_to_embed = self._prepare_texts_to_embed(documents=documents)
212
+ self.warm_up()
213
+ assert self.embedder is not None # noqa: S101
206
214
  embeddings = self.embedder.embed_documents(texts_to_embed)
207
215
 
208
216
  new_documents = []
@@ -89,19 +89,25 @@ class WatsonxTextEmbedder:
89
89
  self.timeout = timeout
90
90
  self.max_retries = max_retries
91
91
 
92
- # Initialize the embeddings client
93
- credentials = Credentials(api_key=api_key.resolve_value(), url=api_base_url)
92
+ self.embedder: Embeddings | None = None
93
+
94
+ def warm_up(self) -> None:
95
+ """Create the Watsonx embeddings client."""
96
+ if self.embedder is not None:
97
+ return
98
+
99
+ credentials = Credentials(api_key=self.api_key.resolve_value(), url=self.api_base_url)
94
100
 
95
101
  params = {}
96
- if truncate_input_tokens is not None:
97
- params["truncate_input_tokens"] = truncate_input_tokens
102
+ if self.truncate_input_tokens is not None:
103
+ params["truncate_input_tokens"] = self.truncate_input_tokens
98
104
 
99
105
  self.embedder = Embeddings(
100
- model_id=model,
106
+ model_id=self.model,
101
107
  credentials=credentials,
102
- project_id=project_id.resolve_value(),
103
- params=params if params else None,
104
- max_retries=max_retries,
108
+ project_id=self.project_id.resolve_value(),
109
+ params=params if params else None, # type: ignore[arg-type]
110
+ max_retries=self.max_retries,
105
111
  )
106
112
 
107
113
  def _get_telemetry_data(self) -> dict[str, Any]:
@@ -163,6 +169,8 @@ class WatsonxTextEmbedder:
163
169
  - 'meta': Information about the model usage
164
170
  """
165
171
  text_to_embed = self._prepare_input(text=text)
172
+ self.warm_up()
173
+ assert self.embedder is not None # noqa: S101
166
174
  embedding = self.embedder.embed_query(text_to_embed)
167
175
  return {
168
176
  "embedding": embedding,
@@ -0,0 +1,6 @@
1
+ # SPDX-FileCopyrightText: 2025-present deepset GmbH <info@deepset.ai>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from haystack_integrations.components.generators.watsonx.chat.chat_generator import WatsonxChatGenerator
5
+
6
+ __all__ = ["WatsonxChatGenerator"]
@@ -201,12 +201,14 @@ class WatsonxChatGenerator:
201
201
  self.streaming_callback = streaming_callback
202
202
  self.tools = tools
203
203
 
204
- self._initialize_client()
204
+ self.client: ModelInference | None = None
205
205
 
206
- def _initialize_client(self) -> None:
207
- """Initialize the Watsonx client with configured credentials."""
208
- credentials = Credentials(api_key=self.api_key.resolve_value(), url=self.api_base_url)
206
+ def warm_up(self) -> None:
207
+ """Create the Watsonx client."""
208
+ if self.client is not None:
209
+ return
209
210
 
211
+ credentials = Credentials(api_key=self.api_key.resolve_value(), url=self.api_base_url)
210
212
  self.client = ModelInference(
211
213
  model_id=self.model,
212
214
  credentials=credentials,
@@ -272,8 +274,9 @@ class WatsonxChatGenerator:
272
274
  A list of ChatMessage instances representing the input messages.
273
275
  If a string is provided, it is converted to a list containing a ChatMessage with user role.
274
276
  :param generation_kwargs:
275
- Additional keyword arguments for text generation. These parameters will potentially override the parameters
276
- passed in the `__init__` method.
277
+ Additional keyword arguments for text generation. These are merged per key with the
278
+ `generation_kwargs` passed at initialization: keys provided here take precedence, keys set only
279
+ at initialization are kept.
277
280
  :param streaming_callback:
278
281
  A callback function that is called when a new token is received from the stream.
279
282
  If provided this will override the `streaming_callback` set in the `__init__` method.
@@ -288,6 +291,9 @@ class WatsonxChatGenerator:
288
291
  if not messages:
289
292
  return {"replies": []}
290
293
 
294
+ self.warm_up()
295
+ assert self.client is not None # noqa: S101
296
+
291
297
  resolved_streaming_callback = select_streaming_callback(
292
298
  init_callback=self.streaming_callback, runtime_callback=streaming_callback, requires_async=False
293
299
  )
@@ -315,8 +321,9 @@ class WatsonxChatGenerator:
315
321
  A list of ChatMessage instances representing the input messages.
316
322
  If a string is provided, it is converted to a list containing a ChatMessage with user role.
317
323
  :param generation_kwargs:
318
- Additional keyword arguments for text generation. These parameters will potentially override the parameters
319
- passed in the `__init__` method.
324
+ Additional keyword arguments for text generation. These are merged per key with the
325
+ `generation_kwargs` passed at initialization: keys provided here take precedence, keys set only
326
+ at initialization are kept.
320
327
  :param streaming_callback:
321
328
  A callback function that is called when a new token is received from the stream.
322
329
  If provided this will override the `streaming_callback` set in the `__init__` method.
@@ -331,6 +338,9 @@ class WatsonxChatGenerator:
331
338
  if not messages:
332
339
  return {"replies": []}
333
340
 
341
+ self.warm_up()
342
+ assert self.client is not None # noqa: S101
343
+
334
344
  resolved_streaming_callback = select_streaming_callback(
335
345
  init_callback=self.streaming_callback, runtime_callback=streaming_callback, requires_async=True
336
346
  )
@@ -352,7 +362,7 @@ class WatsonxChatGenerator:
352
362
  merged_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})}
353
363
 
354
364
  watsonx_messages = []
355
- content: str | None | dict[str, Any] | list[dict[str, Any]]
365
+ content: str | dict[str, Any] | list[dict[str, Any]] | None
356
366
 
357
367
  flattened_tools = flatten_tools_or_toolsets(tools or self.tools)
358
368
  _check_duplicate_tool_names(flattened_tools)
@@ -469,6 +479,7 @@ class WatsonxChatGenerator:
469
479
  :returns:
470
480
  A dictionary with the generated responses as ChatMessage instances.
471
481
  """
482
+ assert self.client is not None # noqa: S101
472
483
  chunks: list[StreamingChunk] = []
473
484
  stream = self.client.chat_stream(
474
485
  messages=api_args["messages"], params=api_args["params"], tools=api_args.get("tools")
@@ -501,6 +512,7 @@ class WatsonxChatGenerator:
501
512
 
502
513
  def _handle_standard(self, api_args: dict[str, Any]) -> dict[str, list[ChatMessage]]:
503
514
  """Handle synchronous standard response."""
515
+ assert self.client is not None # noqa: S101
504
516
  response = self.client.chat(
505
517
  messages=api_args["messages"], params=api_args["params"], tools=api_args.get("tools")
506
518
  )
@@ -513,6 +525,7 @@ class WatsonxChatGenerator:
513
525
  callback: StreamingCallbackT,
514
526
  ) -> dict[str, list[ChatMessage]]:
515
527
  """Handle asynchronous streaming response."""
528
+ assert self.client is not None # noqa: S101
516
529
  chunks: list[StreamingChunk] = []
517
530
  stream_generator = await self.client.achat_stream(
518
531
  messages=api_args["messages"], params=api_args["params"], tools=api_args.get("tools")
@@ -548,6 +561,7 @@ class WatsonxChatGenerator:
548
561
 
549
562
  async def _handle_async_standard(self, api_args: dict[str, Any]) -> dict[str, list[ChatMessage]]:
550
563
  """Handle asynchronous standard response."""
564
+ assert self.client is not None # noqa: S101
551
565
  response = await self.client.achat(
552
566
  messages=api_args["messages"], params=api_args["params"], tools=api_args.get("tools")
553
567
  )