amazon-bedrock-haystack 5.3.0__py3-none-any.whl → 5.3.1__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.3.0
3
+ Version: 5.3.1
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
@@ -10,9 +10,9 @@ haystack_integrations/components/downloaders/s3/__init__.py,sha256=2BOd3_N0kGqRJ
10
10
  haystack_integrations/components/downloaders/s3/s3_downloader.py,sha256=jj9VMQ5QciTZvJ8Qki_zha0tcK0-APm2rMhMPObtr1M,12625
11
11
  haystack_integrations/components/embedders/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  haystack_integrations/components/embedders/amazon_bedrock/__init__.py,sha256=7GlhHJ4jFHCxq5QN5losGuGtrGNjvEx2dSQvEYD2yG0,408
13
- haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py,sha256=vRBdqqIv09dbL9qWWy3BlrwK2P036q2d30zsIzWs-A0,13387
14
- haystack_integrations/components/embedders/amazon_bedrock/document_image_embedder.py,sha256=qpvsJsrJ7wi9mV_euQ4pX3wqcqJjJUPW6dfoYRvi0eM,16212
15
- haystack_integrations/components/embedders/amazon_bedrock/text_embedder.py,sha256=o7ERGCH0F6h3QzULy3yXxGxFxZdeyW8wAz4fPL3pvzQ,9513
13
+ haystack_integrations/components/embedders/amazon_bedrock/document_embedder.py,sha256=EKLiKzN0al7OLvfIAnXXNgUTI4TbSc-qCkfjjDJeCd4,13216
14
+ haystack_integrations/components/embedders/amazon_bedrock/document_image_embedder.py,sha256=qKsWRGkubFMHDeqTbPgA5qvEag_CDNTnc5kEmDbc6IQ,16202
15
+ haystack_integrations/components/embedders/amazon_bedrock/text_embedder.py,sha256=rYmU39q_-9uKANBebcQsPtGE0EjrAkOQSFHL3e6WYag,9349
16
16
  haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  haystack_integrations/components/generators/amazon_bedrock/__init__.py,sha256=lv4NouIVm78YavUssWQrHHP_81u-7j21qW8v1kZMJPQ,284
18
18
  haystack_integrations/components/generators/amazon_bedrock/adapters.py,sha256=SDCi_EA-1OUmTKrnbcql9oQQuLnoAGzF_XwrKnQ1_jk,19628
@@ -23,7 +23,7 @@ haystack_integrations/components/generators/amazon_bedrock/chat/utils.py,sha256=
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=oFNTF2BnKNA1VERiF42ttTFDzxOiaBIA1H5ozLNFFFU,11800
26
- amazon_bedrock_haystack-5.3.0.dist-info/METADATA,sha256=2z-MOhgu2Qp1Jnc56fs6ANIcmZo7ocLfwgtek22dvJY,2228
27
- amazon_bedrock_haystack-5.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
28
- amazon_bedrock_haystack-5.3.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
29
- amazon_bedrock_haystack-5.3.0.dist-info/RECORD,,
26
+ amazon_bedrock_haystack-5.3.1.dist-info/METADATA,sha256=-icmdgZ9-poMEUHeBb470jU0VnpZwAzlHOcaUS57bLA,2228
27
+ amazon_bedrock_haystack-5.3.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
28
+ amazon_bedrock_haystack-5.3.1.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
29
+ amazon_bedrock_haystack-5.3.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  import json
2
- from typing import Any, Literal, Optional
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: Literal[
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. The model has to be specified in the format outlined in the Amazon
94
- Bedrock [documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html).
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
- if not model or model not in SUPPORTED_EMBEDDING_MODELS:
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. Supported models are: {', '.join(SUPPORTED_EMBEDDING_MODELS)}."
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, Literal, Optional
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: Literal[
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
- The Bedrock model to use for calculating embeddings. Pass a valid model ID.
102
- Supported models:
103
- - "amazon.titan-embed-image-v1"
104
- - "cohere.embed-english-v3"
105
- - "cohere.embed-multilingual-v3"
106
- - "cohere.embed-v4:0"
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 or model not in SUPPORTED_EMBEDDING_MODELS:
129
- msg = "Please provide a valid model from the list of supported models: " + ", ".join(
130
- SUPPORTED_EMBEDDING_MODELS
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 = f"Model {self.model} is not supported. Supported models are: {', '.join(SUPPORTED_EMBEDDING_MODELS)}."
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, Literal, Optional
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: Literal[
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. The model has to be specified in the format outlined in the Amazon
83
- Bedrock [documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html).
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 or model not in SUPPORTED_EMBEDDING_MODELS:
96
- msg = "Please provide a valid model from the list of supported models: " + ", ".join(
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"Unsupported model {self.model}. Supported models are: {', '.join(SUPPORTED_EMBEDDING_MODELS)}"
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}