I found it difficult to understand in the docs how to use the AWS Ruby SDK to invoke models on AWS Bedrock.
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
Add this gem:
gem "aws-sdk-bedrockruntime"
Invoke models using the
BedrockRuntime
client.The specific structure of the params to
invoke_model
can be found in the 'Providers' tab of the Bedrock section in AWS, under the specific model you're interested in.I created the ruby-amazon-bedrock gem https://github.com/AAlvAAro/ruby-amazon-bedrock, which is designed to enhance the ease of leveraging the aws-sdk-bedrockruntime gem. It provides a more intuitive interface and abstracts some of the complexities involved in dealing with different payload structures.
Here are a few examples of how you can use it:
I’ve tried to make the documentation as clear as possible, but I’m always looking for feedback to improve it. I hope this gem makes your work with AWS Bedrock a bit smoother. Let me know if it helps or if you have any further questions!