A simple and clear example for implement a chatbot with Bedrock + LangChain + Streamlit. Just install and run the code~ 🚀
pip install -r requirements.txt
streamlit run bedrock/bedrock_chatbot.py
1. Add Dockfile for container enviroment and remove the packages installation! 🎉🎉🎉
You could build your own, and I've also uploaded a public container image at public.ecr.aws for you~
docker run -d -v $HOME/.aws/config:/root/.aws/config:ro -p 8502:8501 public.ecr.aws/shtian/bedrock-claude-3-langchain-streamlit:latest
2. NEW! Mistral Large on Bedrock Supported! 🎉🎉🎉

NEW! Claude 3 Haiku on Bedrock Supported! Let's Go Faster! 🎉🎉🎉

Install via the command:
pip install -r requirements.txt
NEW! Claude 3 Sonnet on Bedrock Supported! New Message API Plus Vision Multimodal Chat! 🎉🎉🎉
Add system prompt option.
NEW! Claude 3 Sonnet on Bedrock Supported! New Message API Plus Vision Multimodal Chat! 🎉🎉🎉
Install langchain from source, for new Bedrock API support.
Note: No need to hack in bedrock code! Just change the langchain_messages state of streamlit in the app code. Complete this code with the help of Claude itself :)
git clone https://github.com/langchain-ai/langchain.git
pip install -e langchain/libs/langchain
Then run the command:
streamlit run bedrock_chatbot_claude_3_sonnet_vision.py
Note: Some details like - smooth history catchup with new message api, support mulitple images in one chat, image keep in the thumbnail in one line, multimodal and text-only mixed chat, no some bump up after rerun and re-initialize, fix lots of format mismatch...
NEW! Claude 3 Sonnet on Bedrock Supported~ Message API Plus Vision Multimodal! 🎉🎉🎉
Extra action needed (till now) - install langchain from source.
Note: A little bit hack for streamlit conversation history format mismatch, and modify langchain community bedrock source code, no impact on BedrockChat invoke ~
git clone https://github.com/davidshtian/langchain.git
pip install -e langchain/libs/langchain
Then run the command:
streamlit run bedrock_chatbot_claude_3_sonnet_vision.py
NEW! Claude 3 Sonnet on Bedrock Supported~ Message API
Extra action needed (till now) - install langchain from source:
git clone https://github.com/langchain-ai/langchain.git
pip install -e langchain/libs/langchain
Note: Only text supported now, vision later!
Then run the command:
streamlit run bedrock_chatbot_claude_3_sonnet.py
The bot is equipped with chat history using ConversationBufferWindowMemory and StreamlitChatMessageHistory, and provided with both simple(batch) and streaming modes. Demo shown as below:
Bedrock_Chat_Fast.mp4
Streaming mode demo shown as below:

