amazon-bedrock-haystack 3.6.0__py3-none-any.whl → 3.6.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.
- {amazon_bedrock_haystack-3.6.0.dist-info → amazon_bedrock_haystack-3.6.1.dist-info}/METADATA +1 -1
- {amazon_bedrock_haystack-3.6.0.dist-info → amazon_bedrock_haystack-3.6.1.dist-info}/RECORD +6 -6
- haystack_integrations/components/rankers/amazon_bedrock/__init__.py +2 -2
- haystack_integrations/components/rankers/amazon_bedrock/ranker.py +28 -6
- {amazon_bedrock_haystack-3.6.0.dist-info → amazon_bedrock_haystack-3.6.1.dist-info}/WHEEL +0 -0
- {amazon_bedrock_haystack-3.6.0.dist-info → amazon_bedrock_haystack-3.6.1.dist-info}/licenses/LICENSE.txt +0 -0
{amazon_bedrock_haystack-3.6.0.dist-info → amazon_bedrock_haystack-3.6.1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amazon-bedrock-haystack
|
|
3
|
-
Version: 3.6.
|
|
3
|
+
Version: 3.6.1
|
|
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
|
|
@@ -10,9 +10,9 @@ haystack_integrations/components/generators/amazon_bedrock/generator.py,sha256=N
|
|
|
10
10
|
haystack_integrations/components/generators/amazon_bedrock/chat/__init__.py,sha256=6GZ8Y3Lw0rLOsOAqi6Tu5mZC977UzQvgDxKpOWr8IQw,110
|
|
11
11
|
haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py,sha256=M9I0sB8LFrXCgoyr5ik2ZPPHyB0b4nJFKX7GARKsk8Y,23384
|
|
12
12
|
haystack_integrations/components/generators/amazon_bedrock/chat/utils.py,sha256=kBSaU_ZqzL-7a7nplezjb4XRBy51pt-4VULoX5lq21A,21148
|
|
13
|
-
haystack_integrations/components/rankers/amazon_bedrock/__init__.py,sha256=
|
|
14
|
-
haystack_integrations/components/rankers/amazon_bedrock/ranker.py,sha256=
|
|
15
|
-
amazon_bedrock_haystack-3.6.
|
|
16
|
-
amazon_bedrock_haystack-3.6.
|
|
17
|
-
amazon_bedrock_haystack-3.6.
|
|
18
|
-
amazon_bedrock_haystack-3.6.
|
|
13
|
+
haystack_integrations/components/rankers/amazon_bedrock/__init__.py,sha256=Zrc3BSVkEaXYpliEi6hKG9bqW4J7DNk93p50SuoyT1Q,107
|
|
14
|
+
haystack_integrations/components/rankers/amazon_bedrock/ranker.py,sha256=x4QEVkbFM-jMFHx-xmk571wtrohnPLtkIWMhCyg4_II,12278
|
|
15
|
+
amazon_bedrock_haystack-3.6.1.dist-info/METADATA,sha256=oRIb-2Nv642N0wmapQgykocVVjxzwM7rG1_TNOoF6Vs,2225
|
|
16
|
+
amazon_bedrock_haystack-3.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
17
|
+
amazon_bedrock_haystack-3.6.1.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
|
|
18
|
+
amazon_bedrock_haystack-3.6.1.dist-info/RECORD,,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .ranker import BedrockRanker
|
|
1
|
+
from .ranker import AmazonBedrockRanker, BedrockRanker
|
|
2
2
|
|
|
3
|
-
__all__ = ["BedrockRanker"]
|
|
3
|
+
__all__ = ["AmazonBedrockRanker", "BedrockRanker"]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from typing import Any, Dict, List, Optional
|
|
2
3
|
|
|
3
4
|
from botocore.exceptions import ClientError
|
|
@@ -16,7 +17,7 @@ MAX_NUM_DOCS_FOR_BEDROCK_RANKER = 1000
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
@component
|
|
19
|
-
class
|
|
20
|
+
class AmazonBedrockRanker:
|
|
20
21
|
"""
|
|
21
22
|
Ranks Documents based on their similarity to the query using Amazon Bedrock's Cohere Rerank model.
|
|
22
23
|
|
|
@@ -30,9 +31,13 @@ class BedrockRanker:
|
|
|
30
31
|
```python
|
|
31
32
|
from haystack import Document
|
|
32
33
|
from haystack.utils import Secret
|
|
33
|
-
from haystack_integrations.components.rankers.amazon_bedrock import
|
|
34
|
+
from haystack_integrations.components.rankers.amazon_bedrock import AmazonBedrockRanker
|
|
34
35
|
|
|
35
|
-
ranker =
|
|
36
|
+
ranker = AmazonBedrockRanker(
|
|
37
|
+
model="cohere.rerank-v3-5:0",
|
|
38
|
+
top_k=2,
|
|
39
|
+
aws_region_name=Secret.from_token("eu-central-1")
|
|
40
|
+
)
|
|
36
41
|
|
|
37
42
|
docs = [Document(content="Paris"), Document(content="Berlin")]
|
|
38
43
|
query = "What is the capital of germany?"
|
|
@@ -40,7 +45,7 @@ class BedrockRanker:
|
|
|
40
45
|
docs = output["documents"]
|
|
41
46
|
```
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
AmazonBedrockRanker uses AWS for authentication. You can use the AWS CLI to authenticate through your IAM.
|
|
44
49
|
For more information on setting up an IAM identity-based policy, see [Amazon Bedrock documentation]
|
|
45
50
|
(https://docs.aws.amazon.com/bedrock/latest/userguide/security_iam_id-based-policy-examples.html).
|
|
46
51
|
|
|
@@ -71,7 +76,7 @@ class BedrockRanker:
|
|
|
71
76
|
msg = "'model' cannot be None or empty string"
|
|
72
77
|
raise ValueError(msg)
|
|
73
78
|
"""
|
|
74
|
-
Creates an instance of the '
|
|
79
|
+
Creates an instance of the 'AmazonBedrockRanker'.
|
|
75
80
|
|
|
76
81
|
:param model: Amazon Bedrock model name for Cohere Rerank. Default is "cohere.rerank-v3-5:0".
|
|
77
82
|
:param top_k: The maximum number of documents to return.
|
|
@@ -140,7 +145,7 @@ class BedrockRanker:
|
|
|
140
145
|
)
|
|
141
146
|
|
|
142
147
|
@classmethod
|
|
143
|
-
def from_dict(cls, data: Dict[str, Any]) -> "
|
|
148
|
+
def from_dict(cls, data: Dict[str, Any]) -> "AmazonBedrockRanker":
|
|
144
149
|
"""
|
|
145
150
|
Deserializes the component from a dictionary.
|
|
146
151
|
|
|
@@ -260,3 +265,20 @@ class BedrockRanker:
|
|
|
260
265
|
except Exception as e:
|
|
261
266
|
msg = f"Error during Amazon Bedrock API call: {e!s}"
|
|
262
267
|
raise AmazonBedrockInferenceError(msg) from e
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class BedrockRanker(AmazonBedrockRanker):
|
|
271
|
+
"""
|
|
272
|
+
Deprecated alias for AmazonBedrockRanker.
|
|
273
|
+
This class will be removed in a future version.
|
|
274
|
+
Please use AmazonBedrockRanker instead.
|
|
275
|
+
"""
|
|
276
|
+
|
|
277
|
+
def __init__(self, *args, **kwargs):
|
|
278
|
+
warnings.warn(
|
|
279
|
+
"BedrockRanker is deprecated and will be removed in a future version. "
|
|
280
|
+
"Please use AmazonBedrockRanker instead.",
|
|
281
|
+
DeprecationWarning,
|
|
282
|
+
stacklevel=2,
|
|
283
|
+
)
|
|
284
|
+
super().__init__(*args, **kwargs)
|
|
File without changes
|
|
File without changes
|