Skip to content

This repository demonstrates on how to integrate MongoDB Atlas with Amazon Bedrock Generative AI service

Notifications You must be signed in to change notification settings

kaizadwadia/genai-mongodb-amazon-bedrock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amazon-bedrock-genai-chatbot

This repository contains code samples for a chatbot using Amazon Bedrock, LangChain & MongpDB Atlas Vector Search.

Gain Model Access from Amazon Bedrock Console

Visit the Amazon Bedrock documentation for instructions on gaining model access. For Claude access, use the us-east-1 or us-west-2 region.

NOTE: This codebase uses the region us-west-2. Please update the region in the .env file if using another region.

Create MongoDB instance

Create a MongoDB instance by following the instructions in the documentation. Note down the host, username, and password.

⚠️ Pay attention to the network setup. If you are using SageMaker studio to go along with this tutorial, you will need to expose the MongoDB instance to the internet.:

Populate instance with embeddings

  1. Create a .env file in the root directory and add the following environment variables:
MDB_HOST="REPLACE_WITH_HOST_NAME.mongodb.net"
MDB_USERNAME="REPLACE_WITH_YOUR_USERNAME"
MDB_PASSWORD="REPLACE_WITH_YOUR_PASSWORD"
  1. Follow the notebook shopping-bot.ipynb to download product data and embed and store in MongoDB Vector

  2. Update the .env file in the root directory and add the collection and database names as well:

MDB_HOST="REPLACE_WITH_HOST_NAME.mongodb.net"
MDB_USERNAME="REPLACE_WITH_YOUR_USERNAME"
MDB_PASSWORD="REPLACE_WITH_YOUR_PASSWORD"
MDB_COLLECTION="REPLACE_WITH_YOUR_COLLECTION"
MDB_DATABASE="REPLACE_WITH_YOUR_DATABASE"

Run streamlit application

streamlit run chatbot_rag.py

Start chatting

While chatting, check your terminal window to see how the chain is running.

NOTE: Set verbose=False for chain ConversationalRetrievalChain in the file langchain.py if you dont want to see detail output.

About

This repository demonstrates on how to integrate MongoDB Atlas with Amazon Bedrock Generative AI service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 57.5%
  • Jupyter Notebook 42.5%