textgrad
textgrad copied to clipboard
Add support for Amazon Bedrock models
Overview
This PR adds support for Amazon Bedrock, allowing TextGrad users to leverage a variety of foundation models from AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API.
Key Changes
- Implemented support for Amazon Bedrock in the
get_enginefunction - Added compatibility for Meta, Anthropic, Cohere, Mistral, and Amazon models
- Introduced a new naming convention for Bedrock models:
bedrock-<model_name_id>(here the model id list)
Usage
To use a Bedrock model, call the get_engine function with the Bedrock model name ID prefixed by "bedrock-". For example:
engine = get_engine("bedrock-anthropic.claude-3-sonnet-20240229-v1:0", max_tokens=2048)
Authentication
The PR supports two authentication methods:
- AWS environment using AWS Roles
- Environment variables:
- AWS_DEFAULT_REGION (optional)
- AWS_SECRET_ACCESS_KEY
- AWS_ACCESS_KEY_ID
- AWS_SESSION_TOKEN (optional)
Supported Models
This PR adds support for the following model families:
- Meta
- Anthropic
- Cohere
- Mistral
- Amazon
A complete list of supported model IDs will be added to the documentation.
Testing
- Tested with various Bedrock models
- Verified authentication methods
- Ensured compatibility with existing TextGrad functionality
Feedback
I welcome any feedback or suggestions for improvement. Please let me know if any additional changes or clarifications are needed.
Hi @mertyg thank you so much for the comments! I modified the requirements and commented out the other two comments (for env variables please check if you need them also at line 6, they are already specified at line 63/68).
I'm happy to implement multiple inputs support but can you please provide me an example to test that out? I'll enable the vision capabilities only for Anthropic models (currently they are the only one to support vision in Amazon bedrock).
thank you!
It would be excellent to see this pushed through opening up quite a lot of models today and in the future.
Hi, I would definitely make use of the bedrock version, do you have an estimated date for this branch ? thx