Skip to content
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

AmazonBedrockGenerator unable to return output #832

Closed
sahil-invent opened this issue Jun 19, 2024 · 2 comments
Closed

AmazonBedrockGenerator unable to return output #832

sahil-invent opened this issue Jun 19, 2024 · 2 comments

Comments

@sahil-invent
Copy link

Describe the bug
The Amazon Bedrock Generator and Chat Generator produces an error when running inference. I think its failing to invoke the model.

To Reproduce
To reproduce the error:
After installing haystack-ai and importing the Amazon Bedrock Generator.
Initialise AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION as global variables.
AWS_DEFAULT_REGION is set to 'eu-west-2'

Run:
generator = AmazonBedrockGenerator(model="anthropic.claude-3-sonnet-20240229-v1:0")
result = generator.run("Who is the best American actor?")
for reply in result["replies"]:
print(reply)

Error produced:
TypeError: sequence item 0: expected str instance, NoneType found
from Line 208 in .haystack_integrations/components/generators/amazon_bedrock/generator.py

Describe your environment (please complete the following information):

  • OS: macOS Sonoma 14.5
  • Haystack version: haystack-ai 2.2.1
  • Integration version: amazon-bedrock-haystack 0.9.0

Happy to add more details if needed.

@sahil-invent sahil-invent added the bug Something isn't working label Jun 19, 2024
@anakin87
Copy link
Member

This code works for me.

import os
from haystack_integrations.components.generators.amazon_bedrock import AmazonBedrockGenerator


os.environ["AWS_ACCESS_KEY_ID"]="..."
os.environ["AWS_SECRET_ACCESS_KEY"]="..."
os.environ["AWS_DEFAULT_REGION"]="eu-west-3"

generator = AmazonBedrockGenerator(model="anthropic.claude-3-sonnet-20240229-v1:0")
result = generator.run("Who is the best American actor?")
print(result)

Please note that not all models are supported in all AWS regions. -> Detailed information

@sahil-invent
Copy link
Author

Apologies was typo in declaring the 'AWS_ACCESS_KEY_ID' where I didn't include the '_ID'. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants