Skip to content

Commit

Permalink
feat: add Amazon Bedrock support (#6226)
Browse files Browse the repository at this point in the history
* Add Bedrock

* Update supported models for Bedrock

* Fix supports and add extract response in Bedrock

* fix errors imports

* improve and refactor supports

* fix install

* fix mypy

* fix pylint

* fix existing tests

* Added Anthropic Bedrock

* fix tests

* fix sagemaker tests

* add default prompt handler, constructor and supports tests

* more tests

* invoke refactoring

* refactor model_kwargs

* fix mypy

* lstrip responses

* Add streaming support

* bump boto3 version

* add class docstrings, better exception names

* fix layer name

* add tests for anthropic and cohere model adapters

* update cohere params

* update ai21 args and add tests

* support cohere command light model

* add tital tests

* better class names

* support meta llama 2 model

* fix streaming support

* more future-proof model adapter selection

* fix import

* fix mypy

* fix pylint for preview

* add tests for streaming

* add release notes

* Apply suggestions from code review

Co-authored-by: Agnieszka Marzec <97166305+agnieszka-m@users.noreply.github.com>

* fix format

* fix tests after msg changes

* fix streaming for cohere

---------

Co-authored-by: tstadel <60758086+tstadel@users.noreply.github.com>
Co-authored-by: tstadel <thomas.stadelmann@deepset.ai>
Co-authored-by: Agnieszka Marzec <97166305+agnieszka-m@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 15, 2023
1 parent 08ec492 commit f998bf4
Show file tree
Hide file tree
Showing 16 changed files with 1,564 additions and 116 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/linting_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ jobs:
uses: tj-actions/changed-files@v40
with:
files: |
**/*.py
files_ignore: |
test/**
rest_api/test/**
haystack/preview/**/*.py
- uses: actions/setup-python@v4
with:
Expand Down
21 changes: 21 additions & 0 deletions haystack/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ class HuggingFaceInferenceUnauthorizedError(HuggingFaceInferenceError):
"""Exception for issues that occur in the HuggingFace inference node due to unauthorized access"""


class AWSConfigurationError(NodeError):
"""Exception raised when AWS is not configured correctly"""

def __init__(self, message: Optional[str] = None, send_message_in_event: bool = False):
super().__init__(message=message, send_message_in_event=send_message_in_event)


class AmazonBedrockConfigurationError(NodeError):
"""Exception raised when AmazonBedrock node is not configured correctly"""

def __init__(self, message: Optional[str] = None, send_message_in_event: bool = False):
super().__init__(message=message, send_message_in_event=send_message_in_event)


class AmazonBedrockInferenceError(NodeError):
"""Exception for issues that occur in the Bedrock inference node"""

def __init__(self, message: Optional[str] = None, send_message_in_event: bool = False):
super().__init__(message=message, send_message_in_event=send_message_in_event)


class SageMakerInferenceError(NodeError):
"""Exception for issues that occur in the SageMaker inference node"""

Expand Down
1 change: 1 addition & 0 deletions haystack/nodes/prompt/invocation_layer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from haystack.nodes.prompt.invocation_layer.cohere import CohereInvocationLayer
from haystack.nodes.prompt.invocation_layer.hugging_face import HFLocalInvocationLayer
from haystack.nodes.prompt.invocation_layer.hugging_face_inference import HFInferenceEndpointInvocationLayer
from haystack.nodes.prompt.invocation_layer.amazon_bedrock import AmazonBedrockInvocationLayer
from haystack.nodes.prompt.invocation_layer.sagemaker_meta import SageMakerMetaInvocationLayer
from haystack.nodes.prompt.invocation_layer.sagemaker_hf_infer import SageMakerHFInferenceInvocationLayer
from haystack.nodes.prompt.invocation_layer.sagemaker_hf_text_gen import SageMakerHFTextGenerationInvocationLayer
Loading

0 comments on commit f998bf4

Please sign in to comment.