-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Amazon Bedrock integration #111
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4d7aa46
Add Amazon Bedrock integration
julian-risch f7376ce
add logo
julian-risch 3fb57b0
Rename amazon-bedrock to amazon-bedrock.md
julian-risch ac15607
Update amazon-bedrock.md
julian-risch c856e2b
Remove mention of embed models
julian-risch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
layout: integration | ||
name: Amazon Bedrock | ||
description: Use Models from AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon via Amazon Bedrock with Haystack | ||
authors: | ||
- name: deepset | ||
socials: | ||
github: deepset-ai | ||
twitter: deepset_ai | ||
linkedin: deepset-ai | ||
pypi: https://pypi.org/project/amazon-bedrock-haystack | ||
repo: https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/amazon_bedrock | ||
type: Model Provider | ||
report_issue: https://github.com/deepset-ai/haystack-core-integrations/issues | ||
logo: /logos/aws.png | ||
version: Haystack 2.0 | ||
toc: true | ||
--- | ||
|
||
### Table of Contents | ||
|
||
- [Overview](#overview) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [AmazonBedrockGenerator](#AmazonBedrockGenerator) | ||
|
||
## Overview | ||
|
||
[Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that makes high-performing foundation models from leading AI startups and Amazon available for your use through a unified API. You can choose from various foundation models to find the one best suited for your use case. More information can be found on the [documentation page](https://docs.haystack.deepset.ai/v2.0/docs/amazonbedrockgenerator). | ||
|
||
## Installation | ||
|
||
Install the Amazon Bedrock integration: | ||
```bash | ||
pip install amazon-bedrock-haystack | ||
``` | ||
|
||
## Usage | ||
|
||
Once installed, you will have access to an AmazonBedrockGenerator that supports models from various providers: | ||
- Anthropic's Claude | ||
- AI21 Labs' Jurassic-2 | ||
- Stability AI's Stable Diffusion | ||
- Cohere's Command and Embed | ||
- Meta's Llama 2 | ||
- Amazon Titan language and embeddings models | ||
|
||
### AmazonBedrockGenerator | ||
|
||
To use this integration for text generation, initialize a `AmazonBedrockGenerator` with the model name and aws credentials: | ||
|
||
```python | ||
from amazon_bedrock_haystack import AmazonBedrockGenerator | ||
|
||
aws_access_key_id="..." | ||
aws_secret_access_key="..." | ||
aws_region_name="eu-central-1" | ||
|
||
generator = AmazonBedrockGenerator(model_name="anthropic.claude-v2", aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, aws_region_name=aws_region_name) | ||
result = generator.run("Who is the best American actor?") | ||
for reply in result["replies"]: | ||
print(reply) | ||
``` | ||
Output: | ||
```shell | ||
'There is no definitive "best" American actor, as acting skill and talent a# re subjective. However, some of the most acclaimed and influential American act# ors include Tom Hanks, Daniel Day-Lewis, Denzel Washington, Meryl Streep, Rober# t De Niro, Al Pacino, Marlon Brando, Jack Nicholson, Leonardo DiCaprio and John# ny Depp. Choosing a single "best" actor comes down to personal preference.' | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we support embedding models? Don't we need another component for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Embedding models are indeed not supported yet. I created an issue to track that: deepset-ai/haystack-core-integrations#181