amazon-bedrock-haystack 5.3.0__tar.gz → 5.4.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-5.3.0 → amazon_bedrock_haystack-5.4.0}/CHANGELOG.md +27 -9
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/PKG-INFO +1 -1
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/pyproject.toml +1 -1
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/downloaders/s3/s3_downloader.py +1 -2
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py +12 -26
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/embedders/amazon_bedrock/document_image_embedder.py +17 -25
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/embedders/amazon_bedrock/text_embedder.py +12 -25
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py +1 -1
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/amazon_bedrock/generator.py +1 -1
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/rankers/amazon_bedrock/ranker.py +1 -1
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_s3_downloader.py +9 -29
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/.gitignore +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/LICENSE.txt +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/README.md +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/bedrock_ranker_example.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/chatgenerator_example.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/embedders_generator_with_rag_example.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/s3_downloader_example.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/pydoc/config_docusaurus.yml +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/amazon_bedrock/errors.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/amazon_bedrock/utils.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/py.typed +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/s3/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/s3/errors.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/common/s3/utils.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/downloaders/py.typed +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/downloaders/s3/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/embedders/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/amazon_bedrock/adapters.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/amazon_bedrock/chat/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/generators/py.typed +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/rankers/amazon_bedrock/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/__init__.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/conftest.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_chat_generator.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_chat_generator_utils.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_document_embedder.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_document_image_embedder.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_files/apple.jpg +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_files/haystack-logo.png +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_files/sample_pdf_1.pdf +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_generator.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_ranker.py +0 -0
- {amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_text_embedder.py +0 -0
|
@@ -1,38 +1,56 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [integrations/amazon_bedrock-v5.
|
|
3
|
+
## [integrations/amazon_bedrock-v5.3.1] - 2025-12-19
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- Relax model name validation for Bedrock Embedders (#2625)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [integrations/amazon_bedrock-v5.3.0] - 2025-12-17
|
|
4
11
|
|
|
5
12
|
### 🚀 Features
|
|
6
13
|
|
|
7
14
|
- `AmazonBedrockChatGenerator` update tools param to ToolsType (#2415)
|
|
15
|
+
- Cohere Embed v4 support in Bedrock (#2612)
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
### 📚 Documentation
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
- Add pydoc configurations for Docusaurus (#2411)
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
### ⚙️ CI
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
- Change pytest command (#2475)
|
|
16
24
|
|
|
17
25
|
### 🧹 Chores
|
|
18
26
|
|
|
19
|
-
-
|
|
27
|
+
- Remove Readme API CI workflow and configs (#2573)
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
### 🌀 Miscellaneous
|
|
30
|
+
|
|
31
|
+
- Adopt PEP 585 type hinting (part 2) (#2508)
|
|
32
|
+
|
|
33
|
+
## [integrations/amazon_bedrock-v5.1.0] - 2025-09-29
|
|
22
34
|
|
|
23
35
|
### 🚀 Features
|
|
24
36
|
|
|
25
|
-
-
|
|
37
|
+
- S3Downloader - add `s3_key_generation_function` param to customize S3 key generation (#2343)
|
|
38
|
+
|
|
26
39
|
|
|
27
|
-
## [integrations/amazon_bedrock-
|
|
40
|
+
## [integrations/amazon_bedrock-v5.0.0] - 2025-09-22
|
|
28
41
|
|
|
29
42
|
### 🚀 Features
|
|
30
43
|
|
|
31
44
|
- Support AWS Bedrock Guardrails in `AmazonBedrockChatGenerator` (#2284)
|
|
45
|
+
- Add a new `S3Downloader` component (#2192)
|
|
46
|
+
|
|
47
|
+
### 📚 Documentation
|
|
48
|
+
|
|
32
49
|
|
|
33
50
|
### 🧹 Chores
|
|
34
51
|
|
|
35
52
|
- Bedrock - remove unused `stop_words` init parameter (#2275)
|
|
53
|
+
- [**breaking**] Remove deprecated `BedrockRanker` (use `AmazonBedrockRanker` instead) (#2287)
|
|
36
54
|
|
|
37
55
|
### 🌀 Miscellaneous
|
|
38
56
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amazon-bedrock-haystack
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.4.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
|
|
@@ -47,7 +47,7 @@ dependencies = ["haystack-pydoc-tools", "ruff"]
|
|
|
47
47
|
|
|
48
48
|
[tool.hatch.envs.default.scripts]
|
|
49
49
|
docs = ["pydoc-markdown pydoc/config_docusaurus.yml"]
|
|
50
|
-
fmt = "ruff check --fix {args}
|
|
50
|
+
fmt = "ruff check --fix {args}; ruff format {args}"
|
|
51
51
|
fmt-check = "ruff check {args} && ruff format --check {args}"
|
|
52
52
|
|
|
53
53
|
[tool.hatch.envs.test]
|
|
@@ -142,8 +142,7 @@ class S3Downloader:
|
|
|
142
142
|
"""
|
|
143
143
|
|
|
144
144
|
if self._storage is None:
|
|
145
|
-
|
|
146
|
-
raise RuntimeError(msg)
|
|
145
|
+
self.warm_up()
|
|
147
146
|
|
|
148
147
|
filtered_documents = self._filter_documents_by_extensions(documents) if self.file_extensions else documents
|
|
149
148
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Any,
|
|
2
|
+
from typing import Any, Optional
|
|
3
3
|
|
|
4
4
|
from botocore.config import Config
|
|
5
5
|
from botocore.exceptions import ClientError
|
|
@@ -16,15 +16,6 @@ from haystack_integrations.common.amazon_bedrock.utils import get_aws_session
|
|
|
16
16
|
|
|
17
17
|
logger = logging.getLogger(__name__)
|
|
18
18
|
|
|
19
|
-
SUPPORTED_EMBEDDING_MODELS = [
|
|
20
|
-
"amazon.titan-embed-text-v1",
|
|
21
|
-
"amazon.titan-embed-text-v2:0",
|
|
22
|
-
"amazon.titan-embed-image-v1",
|
|
23
|
-
"cohere.embed-english-v3",
|
|
24
|
-
"cohere.embed-multilingual-v3",
|
|
25
|
-
"cohere.embed-v4:0",
|
|
26
|
-
]
|
|
27
|
-
|
|
28
19
|
|
|
29
20
|
@component
|
|
30
21
|
class AmazonBedrockDocumentEmbedder:
|
|
@@ -58,14 +49,7 @@ class AmazonBedrockDocumentEmbedder:
|
|
|
58
49
|
|
|
59
50
|
def __init__(
|
|
60
51
|
self,
|
|
61
|
-
model:
|
|
62
|
-
"amazon.titan-embed-text-v1",
|
|
63
|
-
"amazon.titan-embed-text-v2:0",
|
|
64
|
-
"amazon.titan-embed-image-v1",
|
|
65
|
-
"cohere.embed-english-v3",
|
|
66
|
-
"cohere.embed-multilingual-v3",
|
|
67
|
-
"cohere.embed-v4:0",
|
|
68
|
-
],
|
|
52
|
+
model: str,
|
|
69
53
|
aws_access_key_id: Optional[Secret] = Secret.from_env_var("AWS_ACCESS_KEY_ID", strict=False), # noqa: B008
|
|
70
54
|
aws_secret_access_key: Optional[Secret] = Secret.from_env_var( # noqa: B008
|
|
71
55
|
"AWS_SECRET_ACCESS_KEY", strict=False
|
|
@@ -90,8 +74,13 @@ class AmazonBedrockDocumentEmbedder:
|
|
|
90
74
|
constructor. Aside from model, three required parameters are `aws_access_key_id`, `aws_secret_access_key`,
|
|
91
75
|
and `aws_region_name`.
|
|
92
76
|
|
|
93
|
-
:param model: The embedding model to use.
|
|
94
|
-
|
|
77
|
+
:param model: The embedding model to use.
|
|
78
|
+
Amazon Titan and Cohere embedding models are supported, for example:
|
|
79
|
+
"amazon.titan-embed-text-v1", "amazon.titan-embed-text-v2:0", "amazon.titan-embed-image-v1",
|
|
80
|
+
"cohere.embed-english-v3", "cohere.embed-multilingual-v3", "cohere.embed-v4:0".
|
|
81
|
+
To find all supported models, refer to the Amazon Bedrock
|
|
82
|
+
[documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) and
|
|
83
|
+
filter for "embedding", then select models from the Amazon Titan and Cohere series.
|
|
95
84
|
:param aws_access_key_id: AWS access key ID.
|
|
96
85
|
:param aws_secret_access_key: AWS secret access key.
|
|
97
86
|
:param aws_session_token: AWS session token.
|
|
@@ -109,11 +98,8 @@ class AmazonBedrockDocumentEmbedder:
|
|
|
109
98
|
:raises ValueError: If the model is not supported.
|
|
110
99
|
:raises AmazonBedrockConfigurationError: If the AWS environment is not configured correctly.
|
|
111
100
|
"""
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
msg = "Please provide a valid model from the list of supported models: " + ", ".join(
|
|
115
|
-
SUPPORTED_EMBEDDING_MODELS
|
|
116
|
-
)
|
|
101
|
+
if "titan" not in model and "cohere" not in model:
|
|
102
|
+
msg = f"Model {model} is not supported. Only Amazon Titan and Cohere embedding models are supported."
|
|
117
103
|
raise ValueError(msg)
|
|
118
104
|
|
|
119
105
|
self.model = model
|
|
@@ -254,7 +240,7 @@ class AmazonBedrockDocumentEmbedder:
|
|
|
254
240
|
elif "titan" in self.model:
|
|
255
241
|
documents_with_embeddings = self._embed_titan(documents=documents)
|
|
256
242
|
else:
|
|
257
|
-
msg = f"Model {self.model} is not supported.
|
|
243
|
+
msg = f"Model {self.model} is not supported. Only Amazon Titan and Cohere embedding models are supported."
|
|
258
244
|
raise ValueError(msg)
|
|
259
245
|
|
|
260
246
|
return {"documents": documents_with_embeddings}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
from dataclasses import replace
|
|
7
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, Optional
|
|
8
8
|
|
|
9
9
|
from botocore.config import Config
|
|
10
10
|
from botocore.exceptions import ClientError
|
|
@@ -27,13 +27,6 @@ from haystack_integrations.common.amazon_bedrock.utils import get_aws_session
|
|
|
27
27
|
|
|
28
28
|
logger = logging.getLogger(__name__)
|
|
29
29
|
|
|
30
|
-
SUPPORTED_EMBEDDING_MODELS = [
|
|
31
|
-
"amazon.titan-embed-image-v1",
|
|
32
|
-
"cohere.embed-english-v3",
|
|
33
|
-
"cohere.embed-multilingual-v3",
|
|
34
|
-
"cohere.embed-v4:0",
|
|
35
|
-
]
|
|
36
|
-
|
|
37
30
|
|
|
38
31
|
@component
|
|
39
32
|
class AmazonBedrockDocumentImageEmbedder:
|
|
@@ -74,12 +67,7 @@ class AmazonBedrockDocumentImageEmbedder:
|
|
|
74
67
|
def __init__(
|
|
75
68
|
self,
|
|
76
69
|
*,
|
|
77
|
-
model:
|
|
78
|
-
"amazon.titan-embed-image-v1",
|
|
79
|
-
"cohere.embed-english-v3",
|
|
80
|
-
"cohere.embed-multilingual-v3",
|
|
81
|
-
"cohere.embed-v4:0",
|
|
82
|
-
],
|
|
70
|
+
model: str,
|
|
83
71
|
aws_access_key_id: Optional[Secret] = Secret.from_env_var("AWS_ACCESS_KEY_ID", strict=False), # noqa: B008
|
|
84
72
|
aws_secret_access_key: Optional[Secret] = Secret.from_env_var( # noqa: B008
|
|
85
73
|
"AWS_SECRET_ACCESS_KEY", strict=False
|
|
@@ -97,13 +85,13 @@ class AmazonBedrockDocumentImageEmbedder:
|
|
|
97
85
|
"""
|
|
98
86
|
Creates a AmazonBedrockDocumentImageEmbedder component.
|
|
99
87
|
|
|
100
|
-
:param model:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
106
|
-
|
|
88
|
+
:param model: The embedding model to use.
|
|
89
|
+
Amazon Titan and Cohere multimodal embedding models are supported, for example:
|
|
90
|
+
"amazon.titan-embed-image-v1", "cohere.embed-english-v3", "cohere.embed-multilingual-v3",
|
|
91
|
+
"cohere.embed-v4:0".
|
|
92
|
+
To find all supported models, refer to the Amazon Bedrock
|
|
93
|
+
[documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) and
|
|
94
|
+
filter for "embedding", then select multimodal models from the Amazon Titan and Cohere series.
|
|
107
95
|
:param aws_access_key_id: AWS access key ID.
|
|
108
96
|
:param aws_secret_access_key: AWS secret access key.
|
|
109
97
|
:param aws_session_token: AWS session token.
|
|
@@ -125,9 +113,10 @@ class AmazonBedrockDocumentImageEmbedder:
|
|
|
125
113
|
:raises ValueError: If the model is not supported.
|
|
126
114
|
:raises AmazonBedrockConfigurationError: If the AWS environment is not configured correctly.
|
|
127
115
|
"""
|
|
128
|
-
if not model
|
|
129
|
-
msg =
|
|
130
|
-
|
|
116
|
+
if "titan" not in model and "cohere" not in model:
|
|
117
|
+
msg = (
|
|
118
|
+
f"Model {model} is not supported. "
|
|
119
|
+
"Only Amazon Titan and Cohere multimodal embedding models are supported."
|
|
131
120
|
)
|
|
132
121
|
raise ValueError(msg)
|
|
133
122
|
|
|
@@ -291,7 +280,10 @@ class AmazonBedrockDocumentImageEmbedder:
|
|
|
291
280
|
elif "titan" in self.model:
|
|
292
281
|
embeddings = self._embed_titan(images=images_to_embed)
|
|
293
282
|
else:
|
|
294
|
-
msg =
|
|
283
|
+
msg = (
|
|
284
|
+
f"Model {self.model} is not supported. "
|
|
285
|
+
"Only Amazon Titan and Cohere multimodal embedding models are supported."
|
|
286
|
+
)
|
|
295
287
|
raise ValueError(msg)
|
|
296
288
|
|
|
297
289
|
docs_with_embeddings = []
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import Any,
|
|
2
|
+
from typing import Any, Optional
|
|
3
3
|
|
|
4
4
|
from botocore.config import Config
|
|
5
5
|
from botocore.exceptions import ClientError
|
|
@@ -14,15 +14,6 @@ from haystack_integrations.common.amazon_bedrock.utils import get_aws_session
|
|
|
14
14
|
|
|
15
15
|
logger = logging.getLogger(__name__)
|
|
16
16
|
|
|
17
|
-
SUPPORTED_EMBEDDING_MODELS = [
|
|
18
|
-
"amazon.titan-embed-text-v1",
|
|
19
|
-
"amazon.titan-embed-text-v2:0",
|
|
20
|
-
"amazon.titan-embed-image-v1",
|
|
21
|
-
"cohere.embed-english-v3",
|
|
22
|
-
"cohere.embed-multilingual-v3",
|
|
23
|
-
"cohere.embed-v4:0",
|
|
24
|
-
]
|
|
25
|
-
|
|
26
17
|
|
|
27
18
|
@component
|
|
28
19
|
class AmazonBedrockTextEmbedder:
|
|
@@ -51,14 +42,7 @@ class AmazonBedrockTextEmbedder:
|
|
|
51
42
|
|
|
52
43
|
def __init__(
|
|
53
44
|
self,
|
|
54
|
-
model:
|
|
55
|
-
"amazon.titan-embed-text-v1",
|
|
56
|
-
"amazon.titan-embed-text-v2:0",
|
|
57
|
-
"amazon.titan-embed-image-v1",
|
|
58
|
-
"cohere.embed-english-v3",
|
|
59
|
-
"cohere.embed-multilingual-v3",
|
|
60
|
-
"cohere.embed-v4:0",
|
|
61
|
-
],
|
|
45
|
+
model: str,
|
|
62
46
|
aws_access_key_id: Optional[Secret] = Secret.from_env_var("AWS_ACCESS_KEY_ID", strict=False), # noqa: B008
|
|
63
47
|
aws_secret_access_key: Optional[Secret] = Secret.from_env_var( # noqa: B008
|
|
64
48
|
"AWS_SECRET_ACCESS_KEY", strict=False
|
|
@@ -79,8 +63,13 @@ class AmazonBedrockTextEmbedder:
|
|
|
79
63
|
constructor. Aside from model, three required parameters are `aws_access_key_id`, `aws_secret_access_key`,
|
|
80
64
|
and `aws_region_name`.
|
|
81
65
|
|
|
82
|
-
:param model: The embedding model to use.
|
|
83
|
-
|
|
66
|
+
:param model: The embedding model to use.
|
|
67
|
+
Amazon Titan and Cohere embedding models are supported, for example:
|
|
68
|
+
"amazon.titan-embed-text-v1", "amazon.titan-embed-text-v2:0", "amazon.titan-embed-image-v1",
|
|
69
|
+
"cohere.embed-english-v3", "cohere.embed-multilingual-v3", "cohere.embed-v4:0".
|
|
70
|
+
To find all supported models, refer to the Amazon Bedrock
|
|
71
|
+
[documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) and
|
|
72
|
+
filter for "embedding", then select models from the Amazon Titan and Cohere series.
|
|
84
73
|
:param aws_access_key_id: AWS access key ID.
|
|
85
74
|
:param aws_secret_access_key: AWS secret access key.
|
|
86
75
|
:param aws_session_token: AWS session token.
|
|
@@ -92,10 +81,8 @@ class AmazonBedrockTextEmbedder:
|
|
|
92
81
|
:raises ValueError: If the model is not supported.
|
|
93
82
|
:raises AmazonBedrockConfigurationError: If the AWS environment is not configured correctly.
|
|
94
83
|
"""
|
|
95
|
-
if not model
|
|
96
|
-
msg = "
|
|
97
|
-
SUPPORTED_EMBEDDING_MODELS
|
|
98
|
-
)
|
|
84
|
+
if "titan" not in model and "cohere" not in model:
|
|
85
|
+
msg = f"Model {model} is not supported. Only Amazon Titan and Cohere embedding models are supported."
|
|
99
86
|
raise ValueError(msg)
|
|
100
87
|
|
|
101
88
|
self.model = model
|
|
@@ -179,7 +166,7 @@ class AmazonBedrockTextEmbedder:
|
|
|
179
166
|
elif "titan" in self.model:
|
|
180
167
|
embedding = response_body["embedding"]
|
|
181
168
|
else:
|
|
182
|
-
msg = f"
|
|
169
|
+
msg = f"Model {self.model} is not supported. Only Amazon Titan and Cohere embedding models are supported."
|
|
183
170
|
raise ValueError(msg)
|
|
184
171
|
|
|
185
172
|
return {"embedding": embedding}
|
|
@@ -140,7 +140,7 @@ class AmazonBedrockChatGenerator:
|
|
|
140
140
|
automatically from the environment or the AWS configuration file.
|
|
141
141
|
If the AWS environment is not configured, set `aws_access_key_id`, `aws_secret_access_key`,
|
|
142
142
|
and `aws_region_name` as environment variables or pass them as
|
|
143
|
-
[Secret](https://docs.haystack.deepset.ai/
|
|
143
|
+
[Secret](https://docs.haystack.deepset.ai/docs/secret-management) arguments. Make sure the region you set
|
|
144
144
|
supports Amazon Bedrock.
|
|
145
145
|
"""
|
|
146
146
|
|
|
@@ -58,7 +58,7 @@ class AmazonBedrockGenerator:
|
|
|
58
58
|
automatically from the environment or the AWS configuration file.
|
|
59
59
|
If the AWS environment is not configured, set `aws_access_key_id`, `aws_secret_access_key`,
|
|
60
60
|
`aws_session_token`, and `aws_region_name` as environment variables or pass them as
|
|
61
|
-
[Secret](https://docs.haystack.deepset.ai/
|
|
61
|
+
[Secret](https://docs.haystack.deepset.ai/docs/secret-management) arguments. Make sure the region you set
|
|
62
62
|
supports Amazon Bedrock.
|
|
63
63
|
"""
|
|
64
64
|
|
|
@@ -52,7 +52,7 @@ class AmazonBedrockRanker:
|
|
|
52
52
|
automatically from the environment or the AWS configuration file.
|
|
53
53
|
If the AWS environment is not configured, set `aws_access_key_id`, `aws_secret_access_key`,
|
|
54
54
|
and `aws_region_name` as environment variables or pass them as
|
|
55
|
-
[Secret](https://docs.haystack.deepset.ai/
|
|
55
|
+
[Secret](https://docs.haystack.deepset.ai/docs/secret-management) arguments. Make sure the region you set
|
|
56
56
|
supports Amazon Bedrock.
|
|
57
57
|
"""
|
|
58
58
|
|
|
@@ -129,7 +129,6 @@ class TestS3Downloader:
|
|
|
129
129
|
|
|
130
130
|
def test_run(self, tmp_path, mock_s3_storage, mock_boto3_session):
|
|
131
131
|
d = S3Downloader(file_root_path=str(tmp_path))
|
|
132
|
-
S3Downloader.warm_up(d)
|
|
133
132
|
d._storage = mock_s3_storage
|
|
134
133
|
|
|
135
134
|
docs = [
|
|
@@ -141,7 +140,6 @@ class TestS3Downloader:
|
|
|
141
140
|
|
|
142
141
|
def test_run_with_extensions(self, tmp_path, mock_s3_storage, mock_boto3_session):
|
|
143
142
|
d = S3Downloader(file_root_path=str(tmp_path), file_extensions=[".txt"])
|
|
144
|
-
S3Downloader.warm_up(d)
|
|
145
143
|
d._storage = mock_s3_storage
|
|
146
144
|
|
|
147
145
|
docs = [
|
|
@@ -155,12 +153,9 @@ class TestS3Downloader:
|
|
|
155
153
|
|
|
156
154
|
def test_run_with_input_file_meta_key(self, tmp_path, mock_s3_storage, mock_boto3_session):
|
|
157
155
|
d = S3Downloader(file_root_path=str(tmp_path), file_name_meta_key="custom_file_key")
|
|
158
|
-
S3Downloader.warm_up(d)
|
|
159
156
|
d._storage = mock_s3_storage
|
|
160
157
|
|
|
161
|
-
docs = [
|
|
162
|
-
Document(meta={"file_id": str(uuid4()), "custom_file_key": "a.txt"}),
|
|
163
|
-
]
|
|
158
|
+
docs = [Document(meta={"file_id": str(uuid4()), "custom_file_key": "a.txt"})]
|
|
164
159
|
|
|
165
160
|
out = d.run(documents=docs)
|
|
166
161
|
assert len(out["documents"]) == 1
|
|
@@ -168,12 +163,9 @@ class TestS3Downloader:
|
|
|
168
163
|
|
|
169
164
|
def test_run_with_s3_key_generation_function(self, tmp_path, mock_s3_storage, mock_boto3_session):
|
|
170
165
|
d = S3Downloader(file_root_path=str(tmp_path), s3_key_generation_function=s3_key_generation_function)
|
|
171
|
-
S3Downloader.warm_up(d)
|
|
172
166
|
d._storage = mock_s3_storage
|
|
173
167
|
|
|
174
|
-
docs = [
|
|
175
|
-
Document(meta={"file_id": str(uuid4()), "file_name": "a.txt"}),
|
|
176
|
-
]
|
|
168
|
+
docs = [Document(meta={"file_id": str(uuid4()), "file_name": "a.txt"})]
|
|
177
169
|
out = d.run(documents=docs)
|
|
178
170
|
assert len(out["documents"]) == 1
|
|
179
171
|
assert out["documents"][0].meta["file_name"] == "a.txt"
|
|
@@ -189,7 +181,6 @@ class TestS3Downloader:
|
|
|
189
181
|
s3_key_generation_function=s3_key_generation_function,
|
|
190
182
|
file_extensions=[".txt"],
|
|
191
183
|
)
|
|
192
|
-
S3Downloader.warm_up(d)
|
|
193
184
|
d._storage = mock_s3_storage
|
|
194
185
|
|
|
195
186
|
docs = [
|
|
@@ -210,8 +201,6 @@ class TestS3Downloader:
|
|
|
210
201
|
def test_live_run(self, tmp_path, monkeypatch):
|
|
211
202
|
d = S3Downloader(file_root_path=str(tmp_path))
|
|
212
203
|
monkeypatch.setenv("S3_DOWNLOADER_PREFIX", "")
|
|
213
|
-
S3Downloader.warm_up(d)
|
|
214
|
-
|
|
215
204
|
docs = [
|
|
216
205
|
Document(meta={"file_id": str(uuid4()), "file_name": "text-sample.txt"}),
|
|
217
206
|
Document(meta={"file_id": str(uuid4()), "file_name": "document-sample.pdf"}),
|
|
@@ -229,9 +218,7 @@ class TestS3Downloader:
|
|
|
229
218
|
)
|
|
230
219
|
def test_live_run_with_no_documents(self, tmp_path):
|
|
231
220
|
d = S3Downloader(file_root_path=str(tmp_path))
|
|
232
|
-
|
|
233
|
-
docs = []
|
|
234
|
-
out = d.run(documents=docs)
|
|
221
|
+
out = d.run(documents=[])
|
|
235
222
|
assert len(out["documents"]) == 0
|
|
236
223
|
|
|
237
224
|
@pytest.mark.integration
|
|
@@ -247,10 +234,8 @@ class TestS3Downloader:
|
|
|
247
234
|
def test_live_run_with_custom_meta_key(self, tmp_path, monkeypatch):
|
|
248
235
|
d = S3Downloader(file_root_path=str(tmp_path), file_name_meta_key="custom_name")
|
|
249
236
|
monkeypatch.setenv("S3_DOWNLOADER_PREFIX", "")
|
|
250
|
-
|
|
251
|
-
docs = [
|
|
252
|
-
Document(meta={"custom_name": "text-sample.txt"}),
|
|
253
|
-
]
|
|
237
|
+
d.warm_up()
|
|
238
|
+
docs = [Document(meta={"custom_name": "text-sample.txt"})]
|
|
254
239
|
out = d.run(documents=docs)
|
|
255
240
|
assert len(out["documents"]) == 1
|
|
256
241
|
assert out["documents"][0].meta["custom_name"] == "text-sample.txt"
|
|
@@ -263,11 +248,8 @@ class TestS3Downloader:
|
|
|
263
248
|
def test_live_run_with_prefix(self, tmp_path, monkeypatch):
|
|
264
249
|
d = S3Downloader(file_root_path=str(tmp_path))
|
|
265
250
|
monkeypatch.setenv("S3_DOWNLOADER_PREFIX", "subfolder/")
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
docs = [
|
|
269
|
-
Document(meta={"file_name": "employees.json"}),
|
|
270
|
-
]
|
|
251
|
+
d.warm_up()
|
|
252
|
+
docs = [Document(meta={"file_name": "employees.json"})]
|
|
271
253
|
out = d.run(documents=docs)
|
|
272
254
|
assert len(out["documents"]) == 1
|
|
273
255
|
assert out["documents"][0].meta["file_name"] == "employees.json"
|
|
@@ -286,10 +268,8 @@ class TestS3Downloader:
|
|
|
286
268
|
file_name_meta_key="file_name",
|
|
287
269
|
s3_key_generation_function=s3_key_generation_function,
|
|
288
270
|
)
|
|
289
|
-
|
|
290
|
-
docs = [
|
|
291
|
-
Document(meta={"file_name": "dog.jpg"}),
|
|
292
|
-
]
|
|
271
|
+
d.warm_up()
|
|
272
|
+
docs = [Document(meta={"file_name": "dog.jpg"})]
|
|
293
273
|
out = d.run(documents=docs)
|
|
294
274
|
assert len(out["documents"]) == 1
|
|
295
275
|
assert out["documents"][0].meta["file_name"] == "dog.jpg"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/bedrock_ranker_example.py
RENAMED
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/chatgenerator_example.py
RENAMED
|
File without changes
|
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/examples/s3_downloader_example.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_chat_generator.py
RENAMED
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_chat_generator_utils.py
RENAMED
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_document_embedder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_files/haystack-logo.png
RENAMED
|
File without changes
|
{amazon_bedrock_haystack-5.3.0 → amazon_bedrock_haystack-5.4.0}/tests/test_files/sample_pdf_1.pdf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|