amazon-bedrock-haystack 3.11.0__tar.gz → 4.1.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.
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/CHANGELOG.md +24 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/PKG-INFO +3 -3
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/README.md +1 -1
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/pyproject.toml +1 -1
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py +29 -8
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py +169 -180
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_chat_generator.py +61 -15
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_chat_generator_utils.py +408 -236
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_document_image_embedder.py +1 -1
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/.gitignore +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/LICENSE.txt +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/examples/bedrock_ranker_example.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/examples/chatgenerator_example.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/examples/embedders_generator_with_rag_example.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/pydoc/config.yml +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/common/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/common/amazon_bedrock/errors.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/common/amazon_bedrock/utils.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/common/py.typed +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/embedders/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/embedders/amazon_bedrock/document_image_embedder.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/embedders/amazon_bedrock/text_embedder.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/amazon_bedrock/adapters.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/amazon_bedrock/chat/__init__.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/amazon_bedrock/generator.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/generators/py.typed +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/rankers/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/rankers/amazon_bedrock/ranker.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/__init__.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/conftest.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_document_embedder.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_files/apple.jpg +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_files/haystack-logo.png +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_files/sample_pdf_1.pdf +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_generator.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_ranker.py +0 -0
- {amazon_bedrock_haystack-3.11.0 → amazon_bedrock_haystack-4.1.0}/tests/test_text_embedder.py +0 -0
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/amazon_bedrock-v4.0.0] - 2025-08-29
|
|
4
|
+
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
- [**breaking**] Update AmazonBedrockChatGenerator to use the new fields in `StreamingChunk` (#2216)
|
|
8
|
+
- [**breaking**] Use `ReasoningContent` to store reasoning content in `ChatMessage` instead of `ChatMessage.meta` (#2226)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### 🧹 Chores
|
|
12
|
+
|
|
13
|
+
- Standardize readmes - part 2 (#2205)
|
|
14
|
+
|
|
15
|
+
## [integrations/amazon_bedrock-v3.11.0] - 2025-08-21
|
|
16
|
+
|
|
17
|
+
### 🚀 Features
|
|
18
|
+
|
|
19
|
+
- Add `AmazonBedrockDocumentImageEmbedder` component (#2185)
|
|
20
|
+
|
|
21
|
+
### 🧹 Chores
|
|
22
|
+
|
|
23
|
+
- Add framework name into UserAgent header for bedrock integration (#2168)
|
|
24
|
+
- Standardize readmes - part 1 (#2202)
|
|
25
|
+
|
|
26
|
+
|
|
3
27
|
## [integrations/amazon_bedrock-v3.10.0] - 2025-08-06
|
|
4
28
|
|
|
5
29
|
### 🚀 Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amazon-bedrock-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: An integration of Amazon Bedrock as an AmazonBedrockGenerator component.
|
|
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.
|
|
24
|
+
Requires-Dist: haystack-ai>=2.17.1
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
|
|
27
27
|
# amazon-bedrock-haystack
|
|
@@ -31,7 +31,7 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
|
|
32
32
|
- [Integration page](https://haystack.deepset.ai/integrations/amazon-bedrock)
|
|
33
33
|
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/amazon_bedrock/CHANGELOG.md)
|
|
34
|
-
|
|
34
|
+
---
|
|
35
35
|
|
|
36
36
|
## Contributing
|
|
37
37
|
|
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
24
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
25
25
|
]
|
|
26
|
-
dependencies = ["haystack-ai>=2.
|
|
26
|
+
dependencies = ["haystack-ai>=2.17.1", "boto3>=1.28.57", "aioboto3>=14.0.0"]
|
|
27
27
|
|
|
28
28
|
[project.urls]
|
|
29
29
|
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/amazon_bedrock#readme"
|
|
@@ -27,6 +27,7 @@ from haystack_integrations.components.generators.amazon_bedrock.chat.utils impor
|
|
|
27
27
|
_parse_completion_response,
|
|
28
28
|
_parse_streaming_response,
|
|
29
29
|
_parse_streaming_response_async,
|
|
30
|
+
_validate_guardrail_config,
|
|
30
31
|
)
|
|
31
32
|
|
|
32
33
|
logger = logging.getLogger(__name__)
|
|
@@ -154,10 +155,11 @@ class AmazonBedrockChatGenerator:
|
|
|
154
155
|
aws_region_name: Optional[Secret] = Secret.from_env_var(["AWS_DEFAULT_REGION"], strict=False), # noqa: B008
|
|
155
156
|
aws_profile_name: Optional[Secret] = Secret.from_env_var(["AWS_PROFILE"], strict=False), # noqa: B008
|
|
156
157
|
generation_kwargs: Optional[Dict[str, Any]] = None,
|
|
157
|
-
stop_words: Optional[List[str]] = None,
|
|
158
158
|
streaming_callback: Optional[StreamingCallbackT] = None,
|
|
159
159
|
boto3_config: Optional[Dict[str, Any]] = None,
|
|
160
160
|
tools: Optional[Union[List[Tool], Toolset]] = None,
|
|
161
|
+
*,
|
|
162
|
+
guardrail_config: Optional[Dict[str, str]] = None,
|
|
161
163
|
) -> None:
|
|
162
164
|
"""
|
|
163
165
|
Initializes the `AmazonBedrockChatGenerator` with the provided parameters. The parameters are passed to the
|
|
@@ -179,10 +181,6 @@ class AmazonBedrockChatGenerator:
|
|
|
179
181
|
:param generation_kwargs: Keyword arguments sent to the model. These parameters are specific to a model.
|
|
180
182
|
You can find the model specific arguments in the AWS Bedrock API
|
|
181
183
|
[documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html).
|
|
182
|
-
:param stop_words: A list of stop words that stop the model from generating more text
|
|
183
|
-
when encountered. You can provide them using this parameter or using the model's `generation_kwargs`
|
|
184
|
-
under a model's specific key for stop words.
|
|
185
|
-
For example, you can provide stop words for Anthropic Claude in the `stop_sequences` key.
|
|
186
184
|
:param streaming_callback: A callback function called when a new token is received from the stream.
|
|
187
185
|
By default, the model is not set up for streaming. To enable streaming, set this parameter to a callback
|
|
188
186
|
function that handles the streaming chunks. The callback function receives a
|
|
@@ -190,6 +188,19 @@ class AmazonBedrockChatGenerator:
|
|
|
190
188
|
the streaming mode on.
|
|
191
189
|
:param boto3_config: The configuration for the boto3 client.
|
|
192
190
|
:param tools: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name.
|
|
191
|
+
:param guardrail_config: Optional configuration for a guardrail that has been created in Amazon Bedrock.
|
|
192
|
+
This must be provided as a dictionary matching either
|
|
193
|
+
[GuardrailConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailConfiguration.html).
|
|
194
|
+
or, in streaming mode (when `streaming_callback` is set),
|
|
195
|
+
[GuardrailStreamConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_GuardrailStreamConfiguration.html).
|
|
196
|
+
If `trace` is set to `enabled`, the guardrail trace will be included under the `trace` key in the `meta`
|
|
197
|
+
attribute of the resulting `ChatMessage`.
|
|
198
|
+
Note: Enabling guardrails in streaming mode may introduce additional latency.
|
|
199
|
+
To manage this, you can adjust the `streamProcessingMode` parameter.
|
|
200
|
+
See the
|
|
201
|
+
[Guardrails Streaming documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-streaming.html)
|
|
202
|
+
for more information.
|
|
203
|
+
|
|
193
204
|
|
|
194
205
|
:raises ValueError: If the model name is empty or None.
|
|
195
206
|
:raises AmazonBedrockConfigurationError: If the AWS environment is not configured correctly or the model is
|
|
@@ -204,12 +215,15 @@ class AmazonBedrockChatGenerator:
|
|
|
204
215
|
self.aws_session_token = aws_session_token
|
|
205
216
|
self.aws_region_name = aws_region_name
|
|
206
217
|
self.aws_profile_name = aws_profile_name
|
|
207
|
-
self.stop_words = stop_words or []
|
|
208
218
|
self.streaming_callback = streaming_callback
|
|
209
219
|
self.boto3_config = boto3_config
|
|
220
|
+
|
|
210
221
|
_check_duplicate_tool_names(list(tools or [])) # handles Toolset as well
|
|
211
222
|
self.tools = tools
|
|
212
223
|
|
|
224
|
+
_validate_guardrail_config(guardrail_config=guardrail_config, streaming=streaming_callback is not None)
|
|
225
|
+
self.guardrail_config = guardrail_config
|
|
226
|
+
|
|
213
227
|
def resolve_secret(secret: Optional[Secret]) -> Optional[str]:
|
|
214
228
|
return secret.resolve_value() if secret else None
|
|
215
229
|
|
|
@@ -237,7 +251,6 @@ class AmazonBedrockChatGenerator:
|
|
|
237
251
|
raise AmazonBedrockConfigurationError(msg) from exception
|
|
238
252
|
|
|
239
253
|
self.generation_kwargs = generation_kwargs or {}
|
|
240
|
-
self.stop_words = stop_words or []
|
|
241
254
|
self.async_session: Optional[aioboto3.Session] = None
|
|
242
255
|
|
|
243
256
|
def _get_async_session(self) -> aioboto3.Session:
|
|
@@ -291,11 +304,11 @@ class AmazonBedrockChatGenerator:
|
|
|
291
304
|
aws_region_name=self.aws_region_name.to_dict() if self.aws_region_name else None,
|
|
292
305
|
aws_profile_name=self.aws_profile_name.to_dict() if self.aws_profile_name else None,
|
|
293
306
|
model=self.model,
|
|
294
|
-
stop_words=self.stop_words,
|
|
295
307
|
generation_kwargs=self.generation_kwargs,
|
|
296
308
|
streaming_callback=callback_name,
|
|
297
309
|
boto3_config=self.boto3_config,
|
|
298
310
|
tools=serialize_tools_or_toolset(self.tools),
|
|
311
|
+
guardrail_config=self.guardrail_config,
|
|
299
312
|
)
|
|
300
313
|
|
|
301
314
|
@classmethod
|
|
@@ -308,6 +321,12 @@ class AmazonBedrockChatGenerator:
|
|
|
308
321
|
Instance of `AmazonBedrockChatGenerator`.
|
|
309
322
|
"""
|
|
310
323
|
init_params = data.get("init_parameters", {})
|
|
324
|
+
|
|
325
|
+
stop_words = init_params.pop("stop_words", None)
|
|
326
|
+
msg = "stop_words parameter will be ignored. Use the `stopSequences` key in `generation_kwargs` instead."
|
|
327
|
+
if stop_words:
|
|
328
|
+
logger.warning(msg)
|
|
329
|
+
|
|
311
330
|
serialized_callback_handler = init_params.get("streaming_callback")
|
|
312
331
|
if serialized_callback_handler:
|
|
313
332
|
data["init_parameters"]["streaming_callback"] = deserialize_callable(serialized_callback_handler)
|
|
@@ -387,6 +406,8 @@ class AmazonBedrockChatGenerator:
|
|
|
387
406
|
params["toolConfig"] = tool_config
|
|
388
407
|
if additional_fields:
|
|
389
408
|
params["additionalModelRequestFields"] = additional_fields
|
|
409
|
+
if self.guardrail_config:
|
|
410
|
+
params["guardrailConfig"] = self.guardrail_config
|
|
390
411
|
|
|
391
412
|
# overloads that exhaust finite Literals(bool) not treated as exhaustive
|
|
392
413
|
# see https://github.com/python/mypy/issues/14764
|