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

Add Amazon Bedrock support #97

Merged
merged 6 commits into from
Nov 23, 2024

Conversation

kmotohas
Copy link
Contributor

Overview

This pull request adds support for Amazon Bedrock, AWS's generative AI service, as a backend for LLM and embedding models in nano-graphrag.

Changes

  • Integration of Asynchronous AWS SDK for Python (aioboto3)
  • Implementation of LLM interface for Amazon Bedrock
    • Added support for Claude 3.5 Haiku, Claude 3 Haiku, and Claude 3 Sonnet models
    • Implemented amazon_bedrock_complete_if_cache function for model inference
  • Implementation of embedding interface for Amazon Bedrock
    • Added amazon_bedrock_embedding function using Titan Embed Text v2 model
  • Updated configuration options to include Amazon Bedrock support
  • Modified existing functions to accommodate Amazon Bedrock integration

How to Test

  1. Set up AWS credentials:
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1  # or your preferred region
  1. Update your code to use Amazon Bedrock models and embeddings
graph_func = GraphRAG(working_dir="./working_dir", using_amazon_bedrock=True)

Note

  • Ensure proper IAM permissions are set up for accessing Amazon Bedrock

@gusye1234
Copy link
Owner

LGTM! Would you mind update the readme as well? Maybe add a tip at https://github.com/gusye1234/nano-graphrag?tab=readme-ov-file#quick-start, So people know they can use Claude through Amazon Bedrock

@kmotohas
Copy link
Contributor Author

@gusye1234 Thank you for the review! I have added tips to use Amazon Bedrock in README.md. I also modified to use a factory function to create functions for Amazon Bedrock completion instead of defining one for each model ID to keep pace with service updates.

@gusye1234 gusye1234 merged commit 18fa3a4 into gusye1234:main Nov 23, 2024
1 check passed
@kmotohas kmotohas deleted the feat/Amazon-Bedrock-support branch November 25, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants