Skip to content

Commit

Permalink
Update amazon-bedrock tile for AmazonBedrockChatGenerator (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje authored Feb 8, 2024
1 parent 9c1e629 commit f409433
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions integrations/amazon-bedrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ toc: true
- [Installation](#installation)
- [Usage](#usage)
- [AmazonBedrockGenerator](#AmazonBedrockGenerator)
- [AmazonBedrockChatGenerator](#AmazonBedrockChatGenerator)

## Overview

Expand Down Expand Up @@ -64,3 +65,32 @@ 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.'
```

### AmazonBedrockChatGenerator

To use this integration for chat models, initialize a `AmazonBedrockChatGenerator` with the model name and aws credentials:

Currently, the following models are supported:
- Anthropic's Claude
- Meta's Llama 2


```python
from haystack_integrations.components.generators.amazon_bedrock import AmazonBedrockChatGenerator
from haystack.dataclasses import ChatMessage

generator = AmazonBedrockChatGenerator(model="meta.llama2-70b-chat-v1")
messages = [ChatMessage.from_system("You are a helpful assistant that answers question in Spanish only"),
ChatMessage.from_user("What's Natural Language Processing? Be brief.")]

response = generator.run(messages)
print(response)

```
Output:
```shell
{'replies': [ChatMessage(content=' Procesamiento del Lenguaje Natural (PLN) es una rama de la inteligencia artificial que se enfoca en el desarrollo de algoritmos y modelos computacionales para analizar, comprender y generar texto y lenguaje humano.', role=<ChatRole.ASSISTANT: 'assistant'>, name=None, meta={'prompt_token_count': 46, 'generation_token_count': 60, 'stop_reason': 'stop'})]}
```



0 comments on commit f409433

Please sign in to comment.