amazon-bedrock-haystack 5.1.0__py3-none-any.whl → 5.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amazon-bedrock-haystack
3
- Version: 5.1.0
3
+ Version: 5.2.0
4
4
  Summary: An integration of AWS S3 and Bedrock as a Downloader and Generator components.
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/amazon_bedrock#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
21
21
  Requires-Python: >=3.9
22
22
  Requires-Dist: aioboto3>=14.0.0
23
23
  Requires-Dist: boto3>=1.28.57
24
- Requires-Dist: haystack-ai>=2.17.1
24
+ Requires-Dist: haystack-ai>=2.19.0
25
25
  Description-Content-Type: text/markdown
26
26
 
27
27
  # amazon-bedrock-haystack
@@ -18,12 +18,12 @@ haystack_integrations/components/generators/amazon_bedrock/__init__.py,sha256=lv
18
18
  haystack_integrations/components/generators/amazon_bedrock/adapters.py,sha256=yBC-3YwV6qAwSXMtdZiLSYh2lUpPQIDy7Efl7w-Cu-k,19640
19
19
  haystack_integrations/components/generators/amazon_bedrock/generator.py,sha256=Brzw0XvtPJhz2kR2I3liAqWHRmDR6p5HzJerEAPhoJU,14743
20
20
  haystack_integrations/components/generators/amazon_bedrock/chat/__init__.py,sha256=6GZ8Y3Lw0rLOsOAqi6Tu5mZC977UzQvgDxKpOWr8IQw,110
21
- haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py,sha256=qArwfXcforWnPzLXrAW-1hkPFpMy3NSdDyJ5GOta25w,26068
21
+ haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py,sha256=fwjNUrQM4UziGBVZKvsVEZVcKPF00ZY7CY0g2Advwxs,26246
22
22
  haystack_integrations/components/generators/amazon_bedrock/chat/utils.py,sha256=1M_k8CG2WH23Yz-sB7a1kiIqVh2QB8Pqi0zbWXyMUL8,27255
23
23
  haystack_integrations/components/rankers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  haystack_integrations/components/rankers/amazon_bedrock/__init__.py,sha256=mJQKShAP5AfZvfKQisSh7kfKu6RIXzsYdk4eqMtcaEk,75
25
25
  haystack_integrations/components/rankers/amazon_bedrock/ranker.py,sha256=QWtUKfJxMrlfLCWTb8cCP-lKEthnEBwnTd1NSbiFMkg,11812
26
- amazon_bedrock_haystack-5.1.0.dist-info/METADATA,sha256=W5IZ1NhzQ11GjMXl5WrDjRJ0MHnV8jpAHAMyZwNe4Yo,2228
27
- amazon_bedrock_haystack-5.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- amazon_bedrock_haystack-5.1.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
29
- amazon_bedrock_haystack-5.1.0.dist-info/RECORD,,
26
+ amazon_bedrock_haystack-5.2.0.dist-info/METADATA,sha256=DO5DjQps1pXcLOiyLmzvoRnf4xgMKE0kYSSFPiFfQeo,2228
27
+ amazon_bedrock_haystack-5.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ amazon_bedrock_haystack-5.2.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
29
+ amazon_bedrock_haystack-5.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
- from typing import Any, Dict, List, Optional, Tuple, Union
1
+ from typing import Any, Dict, List, Optional, Tuple
2
2
 
3
3
  import aioboto3
4
4
  from botocore.config import Config
@@ -7,10 +7,10 @@ from botocore.exceptions import ClientError
7
7
  from haystack import component, default_from_dict, default_to_dict, logging
8
8
  from haystack.dataclasses import ChatMessage, ComponentInfo, StreamingCallbackT, select_streaming_callback
9
9
  from haystack.tools import (
10
- Tool,
11
- Toolset,
10
+ ToolsType,
12
11
  _check_duplicate_tool_names,
13
12
  deserialize_tools_or_toolset_inplace,
13
+ flatten_tools_or_toolsets,
14
14
  serialize_tools_or_toolset,
15
15
  )
16
16
  from haystack.utils.auth import Secret, deserialize_secrets_inplace
@@ -157,7 +157,7 @@ class AmazonBedrockChatGenerator:
157
157
  generation_kwargs: Optional[Dict[str, Any]] = None,
158
158
  streaming_callback: Optional[StreamingCallbackT] = None,
159
159
  boto3_config: Optional[Dict[str, Any]] = None,
160
- tools: Optional[Union[List[Tool], Toolset]] = None,
160
+ tools: Optional[ToolsType] = None,
161
161
  *,
162
162
  guardrail_config: Optional[Dict[str, str]] = None,
163
163
  ) -> None:
@@ -187,7 +187,8 @@ class AmazonBedrockChatGenerator:
187
187
  [StreamingChunk](https://docs.haystack.deepset.ai/docs/data-classes#streamingchunk) object and switches
188
188
  the streaming mode on.
189
189
  :param boto3_config: The configuration for the boto3 client.
190
- :param tools: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name.
190
+ :param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
191
+ Each tool should have a unique name.
191
192
  :param guardrail_config: Optional configuration for a guardrail that has been created in Amazon Bedrock.
192
193
  This must be provided as a dictionary matching either
193
194
  [GuardrailConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailConfiguration.html).
@@ -218,7 +219,7 @@ class AmazonBedrockChatGenerator:
218
219
  self.streaming_callback = streaming_callback
219
220
  self.boto3_config = boto3_config
220
221
 
221
- _check_duplicate_tool_names(list(tools or [])) # handles Toolset as well
222
+ _check_duplicate_tool_names(flatten_tools_or_toolsets(tools))
222
223
  self.tools = tools
223
224
 
224
225
  _validate_guardrail_config(guardrail_config=guardrail_config, streaming=streaming_callback is not None)
@@ -342,7 +343,7 @@ class AmazonBedrockChatGenerator:
342
343
  messages: List[ChatMessage],
343
344
  streaming_callback: Optional[StreamingCallbackT] = None,
344
345
  generation_kwargs: Optional[Dict[str, Any]] = None,
345
- tools: Optional[Union[List[Tool], Toolset]] = None,
346
+ tools: Optional[ToolsType] = None,
346
347
  requires_async: bool = False,
347
348
  ) -> Tuple[Dict[str, Any], Optional[StreamingCallbackT]]:
348
349
  """
@@ -358,7 +359,8 @@ class AmazonBedrockChatGenerator:
358
359
  - `stopSequences`: List of stop sequences to stop generation.
359
360
  - `temperature`: Sampling temperature.
360
361
  - `topP`: Nucleus sampling parameter.
361
- :param tools: Optional list of Tool objects or a Toolset that the model can use.
362
+ :param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
363
+ Each tool should have a unique name.
362
364
  :param requires_async: Boolean flag to indicate if an async-compatible streaming callback function is needed.
363
365
 
364
366
  :returns:
@@ -380,14 +382,12 @@ class AmazonBedrockChatGenerator:
380
382
 
381
383
  # Handle tools - either toolConfig or Haystack Tool objects but not both
382
384
  tools = tools or self.tools
383
- _check_duplicate_tool_names(list(tools or []))
385
+ flattened_tools = flatten_tools_or_toolsets(tools)
386
+ _check_duplicate_tool_names(flattened_tools)
384
387
  tool_config = merged_kwargs.pop("toolConfig", None)
385
- if tools:
386
- # Convert Toolset to list if needed
387
- if isinstance(tools, Toolset):
388
- tools = list(tools)
388
+ if flattened_tools:
389
389
  # Format Haystack tools to Bedrock format
390
- tool_config = _format_tools(tools)
390
+ tool_config = _format_tools(flattened_tools)
391
391
 
392
392
  # Any remaining kwargs go to additionalModelRequestFields
393
393
  additional_fields = merged_kwargs if merged_kwargs else None
@@ -425,7 +425,7 @@ class AmazonBedrockChatGenerator:
425
425
  messages: List[ChatMessage],
426
426
  streaming_callback: Optional[StreamingCallbackT] = None,
427
427
  generation_kwargs: Optional[Dict[str, Any]] = None,
428
- tools: Optional[Union[List[Tool], Toolset]] = None,
428
+ tools: Optional[ToolsType] = None,
429
429
  ) -> Dict[str, List[ChatMessage]]:
430
430
  """
431
431
  Executes a synchronous inference call to the Amazon Bedrock model using the Converse API.
@@ -439,7 +439,8 @@ class AmazonBedrockChatGenerator:
439
439
  - `stopSequences`: List of stop sequences to stop generation.
440
440
  - `temperature`: Sampling temperature.
441
441
  - `topP`: Nucleus sampling parameter.
442
- :param tools: Optional list of Tools that the model may call during execution.
442
+ :param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
443
+ Each tool should have a unique name.
443
444
 
444
445
  :returns:
445
446
  A dictionary containing the model-generated replies under the `"replies"` key.
@@ -485,7 +486,7 @@ class AmazonBedrockChatGenerator:
485
486
  messages: List[ChatMessage],
486
487
  streaming_callback: Optional[StreamingCallbackT] = None,
487
488
  generation_kwargs: Optional[Dict[str, Any]] = None,
488
- tools: Optional[Union[List[Tool], Toolset]] = None,
489
+ tools: Optional[ToolsType] = None,
489
490
  ) -> Dict[str, List[ChatMessage]]:
490
491
  """
491
492
  Executes an asynchronous inference call to the Amazon Bedrock model using the Converse API.
@@ -499,7 +500,8 @@ class AmazonBedrockChatGenerator:
499
500
  - `stopSequences`: List of stop sequences to stop generation.
500
501
  - `temperature`: Sampling temperature.
501
502
  - `topP`: Nucleus sampling parameter.
502
- :param tools: Optional list of Tool objects or a Toolset that the model can use.
503
+ :param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
504
+ Each tool should have a unique name.
503
505
 
504
506
  :returns:
505
507
  A dictionary containing the model-generated replies under the `"replies"` key.