amazon-bedrock-haystack 6.2.0__py3-none-any.whl → 6.3.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.
- {amazon_bedrock_haystack-6.2.0.dist-info → amazon_bedrock_haystack-6.3.0.dist-info}/METADATA +2 -2
- {amazon_bedrock_haystack-6.2.0.dist-info → amazon_bedrock_haystack-6.3.0.dist-info}/RECORD +6 -6
- haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py +15 -11
- haystack_integrations/components/generators/amazon_bedrock/chat/utils.py +38 -18
- {amazon_bedrock_haystack-6.2.0.dist-info → amazon_bedrock_haystack-6.3.0.dist-info}/WHEEL +0 -0
- {amazon_bedrock_haystack-6.2.0.dist-info → amazon_bedrock_haystack-6.3.0.dist-info}/licenses/LICENSE.txt +0 -0
{amazon_bedrock_haystack-6.2.0.dist-info → amazon_bedrock_haystack-6.3.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amazon-bedrock-haystack
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.3.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
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
21
|
Requires-Dist: aioboto3>=14.0.0
|
|
22
22
|
Requires-Dist: boto3>=1.28.57
|
|
23
|
-
Requires-Dist: haystack-ai>=2.
|
|
23
|
+
Requires-Dist: haystack-ai>=2.23.0
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
|
|
26
26
|
# 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=4-gIWfw70hGaXMNS30UbJFNFCWK2KG6RMnT_4z5RHxc,19625
|
|
19
19
|
haystack_integrations/components/generators/amazon_bedrock/generator.py,sha256=jz9hT3ZMJtUsQnyeCa1sbeEf7e37t3EktQLAT8J2qpM,14901
|
|
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=
|
|
22
|
-
haystack_integrations/components/generators/amazon_bedrock/chat/utils.py,sha256=
|
|
21
|
+
haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py,sha256=C2hB0Wg_oxSnvPAIrTB4eHqjn8a732HfhbhYmS9eGjc,27731
|
|
22
|
+
haystack_integrations/components/generators/amazon_bedrock/chat/utils.py,sha256=oHpDOlIQgRVLhzoMYl1gicq8zyp8uJSstDuRYBVr7Fo,28019
|
|
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=L-1AzmsWR8PYb8CEJsfoYK9MBrE2qXFjenfiiGxa6iw,11769
|
|
26
|
-
amazon_bedrock_haystack-6.
|
|
27
|
-
amazon_bedrock_haystack-6.
|
|
28
|
-
amazon_bedrock_haystack-6.
|
|
29
|
-
amazon_bedrock_haystack-6.
|
|
26
|
+
amazon_bedrock_haystack-6.3.0.dist-info/METADATA,sha256=NvT0-Lm7PU3H0gCayJ-9ahhuftT__KX9wx_tQefvohw,2179
|
|
27
|
+
amazon_bedrock_haystack-6.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
28
|
+
amazon_bedrock_haystack-6.3.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
|
|
29
|
+
amazon_bedrock_haystack-6.3.0.dist-info/RECORD,,
|
|
@@ -423,27 +423,31 @@ class AmazonBedrockChatGenerator:
|
|
|
423
423
|
|
|
424
424
|
def _resolve_flattened_generation_kwargs(self, generation_kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
425
425
|
generation_kwargs = generation_kwargs.copy()
|
|
426
|
-
if "disable_parallel_tool_use" in generation_kwargs:
|
|
427
|
-
disable_parallel_tool_use = generation_kwargs.pop("disable_parallel_tool_use")
|
|
428
|
-
tool_choice = generation_kwargs.setdefault("tool_choice", {})
|
|
429
|
-
tool_choice["disable_parallel_tool_use"] = disable_parallel_tool_use
|
|
430
426
|
|
|
431
|
-
|
|
432
|
-
|
|
427
|
+
disable_parallel_tool_use = generation_kwargs.pop("disable_parallel_tool_use", None)
|
|
428
|
+
parallel_tool_use = generation_kwargs.pop("parallel_tool_use", None)
|
|
429
|
+
|
|
430
|
+
if disable_parallel_tool_use is not None and parallel_tool_use is not None:
|
|
431
|
+
msg = "Cannot set both disable_parallel_tool_use and parallel_tool_use"
|
|
432
|
+
raise ValueError(msg)
|
|
433
|
+
elif parallel_tool_use is not None:
|
|
433
434
|
disable_parallel_tool_use = not parallel_tool_use
|
|
435
|
+
|
|
436
|
+
if disable_parallel_tool_use is not None:
|
|
434
437
|
tool_choice = generation_kwargs.setdefault("tool_choice", {})
|
|
435
438
|
tool_choice["disable_parallel_tool_use"] = disable_parallel_tool_use
|
|
439
|
+
tool_choice.setdefault("type", "auto") # default value
|
|
436
440
|
|
|
437
|
-
|
|
438
|
-
|
|
441
|
+
tool_choice_type = generation_kwargs.pop("tool_choice_type", None)
|
|
442
|
+
if tool_choice_type is not None:
|
|
439
443
|
tool_choice = generation_kwargs.setdefault("tool_choice", {})
|
|
440
444
|
tool_choice["type"] = tool_choice_type
|
|
441
445
|
|
|
442
|
-
|
|
443
|
-
|
|
446
|
+
thinking_budget_tokens = generation_kwargs.pop("thinking_budget_tokens", None)
|
|
447
|
+
if thinking_budget_tokens is not None:
|
|
444
448
|
thinking = generation_kwargs.setdefault("thinking", {})
|
|
445
449
|
thinking["budget_tokens"] = thinking_budget_tokens
|
|
446
|
-
thinking
|
|
450
|
+
thinking.setdefault("type", "enabled")
|
|
447
451
|
|
|
448
452
|
return generation_kwargs
|
|
449
453
|
|
|
@@ -60,6 +60,24 @@ def _format_tools(tools: list[Tool] | None = None) -> dict[str, Any] | None:
|
|
|
60
60
|
return {"tools": tool_specs} if tool_specs else None
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
def _convert_image_content_to_bedrock_format(image_content: ImageContent) -> dict[str, Any]:
|
|
64
|
+
"""
|
|
65
|
+
Convert a Haystack ImageContent to Bedrock format.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
image_format = image_content.mime_type.split("/")[-1] if image_content.mime_type else None
|
|
69
|
+
if image_format not in IMAGE_SUPPORTED_FORMATS:
|
|
70
|
+
err_msg = (
|
|
71
|
+
f"Unsupported image format: {image_format}. "
|
|
72
|
+
f"Bedrock supports the following image formats: {IMAGE_SUPPORTED_FORMATS}"
|
|
73
|
+
)
|
|
74
|
+
raise ValueError(err_msg)
|
|
75
|
+
|
|
76
|
+
source = {"bytes": base64.b64decode(image_content.base64_image)}
|
|
77
|
+
|
|
78
|
+
return {"image": {"format": image_format, "source": source}}
|
|
79
|
+
|
|
80
|
+
|
|
63
81
|
def _format_tool_call_message(tool_call_message: ChatMessage) -> dict[str, Any]:
|
|
64
82
|
"""
|
|
65
83
|
Format a Haystack ChatMessage containing tool calls into Bedrock format.
|
|
@@ -94,19 +112,30 @@ def _format_tool_result_message(tool_call_result_message: ChatMessage) -> dict[s
|
|
|
94
112
|
"""
|
|
95
113
|
# Assuming tool call result messages will only contain tool results
|
|
96
114
|
tool_results = []
|
|
97
|
-
for
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
115
|
+
for tool_call_result in tool_call_result_message.tool_call_results:
|
|
116
|
+
if isinstance(tool_call_result.result, str):
|
|
117
|
+
try:
|
|
118
|
+
json_result = json.loads(tool_call_result.result)
|
|
119
|
+
content = [{"json": json_result}]
|
|
120
|
+
except json.JSONDecodeError:
|
|
121
|
+
content = [{"text": tool_call_result.result}]
|
|
122
|
+
elif isinstance(tool_call_result.result, list):
|
|
123
|
+
content = []
|
|
124
|
+
for item in tool_call_result.result:
|
|
125
|
+
if isinstance(item, TextContent):
|
|
126
|
+
content.append({"text": item.text})
|
|
127
|
+
elif isinstance(item, ImageContent):
|
|
128
|
+
content.append(_convert_image_content_to_bedrock_format(item))
|
|
129
|
+
else:
|
|
130
|
+
err_msg = "Unsupported content type in tool call result"
|
|
131
|
+
raise ValueError(err_msg)
|
|
103
132
|
|
|
104
133
|
tool_results.append(
|
|
105
134
|
{
|
|
106
135
|
"toolResult": {
|
|
107
|
-
"toolUseId":
|
|
136
|
+
"toolUseId": tool_call_result.origin.id,
|
|
108
137
|
"content": content,
|
|
109
|
-
**({"status": "error"} if
|
|
138
|
+
**({"status": "error"} if tool_call_result.error else {}),
|
|
110
139
|
}
|
|
111
140
|
}
|
|
112
141
|
)
|
|
@@ -217,16 +246,7 @@ def _format_text_image_message(message: ChatMessage) -> dict[str, Any]:
|
|
|
217
246
|
if message.is_from(ChatRole.ASSISTANT):
|
|
218
247
|
err_msg = "Image content is not supported for assistant messages"
|
|
219
248
|
raise ValueError(err_msg)
|
|
220
|
-
|
|
221
|
-
image_format = part.mime_type.split("/")[-1] if part.mime_type else None
|
|
222
|
-
if image_format not in IMAGE_SUPPORTED_FORMATS:
|
|
223
|
-
err_msg = (
|
|
224
|
-
f"Unsupported image format: {image_format}. "
|
|
225
|
-
f"Bedrock supports the following image formats: {IMAGE_SUPPORTED_FORMATS}"
|
|
226
|
-
)
|
|
227
|
-
raise ValueError(err_msg)
|
|
228
|
-
source = {"bytes": base64.b64decode(part.base64_image)}
|
|
229
|
-
bedrock_content_blocks.append({"image": {"format": image_format, "source": source}})
|
|
249
|
+
bedrock_content_blocks.append(_convert_image_content_to_bedrock_format(part))
|
|
230
250
|
|
|
231
251
|
return {"role": message.role.value, "content": bedrock_content_blocks}
|
|
232
252
|
|
|
File without changes
|
|
File without changes
|