zou-group / textgrad

Automatic ''Differentiation'' via Text -- using large language models to backpropagate textual gradients.
http://textgrad.com/
MIT License
944 stars 67 forks source link

Add support for Amazon Bedrock models #35

Open Cerrix opened 6 days ago

Cerrix commented 6 days ago

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

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:

  1. AWS environment using AWS Roles
  2. Environment variables:

Supported Models

This PR adds support for the following model families:

A complete list of supported model IDs will be added to the documentation.

Testing

Feedback

I welcome any feedback or suggestions for improvement. Please let me know if any additional changes or clarifications are needed.