Quickly build Generative AI applications with Amazon Bedrock
Provides runnable code samples for image generation, text tasks, chatbots, and RAG using Amazon Bedrock foundation models.
What this file does
Provides runnable code samples for image generation, text tasks, chatbots, and RAG using Amazon Bedrock foundation models.
When to use it
- Starting a new Amazon Bedrock project and need working examples
- Learning how to integrate Bedrock with Streamlit and LangChain
- Exploring RAG implementation with Bedrock and LangChain
- Quickly prototyping generative AI applications
Assumes this stack
Quickly build Generative AI applications with Amazon Bedrock
This repository contains code samples for building diverse AI applications using Amazon Bedrock's foundation models. Learn how to accelerate projects in image and text generation and beyond.
Getting Started
To get a local copy up and running, follow these simple steps.
Prerequisites
- Python 3.9 or higher
- pip
- Model Access in Amazon Bedrock
Installation
Clone the repo
git clone https://github.com/build-on-aws/amazon-bedrock-quick-start.git
Install required packages
pip install -r requirements.txt
Usage
This repository contains various code samples demonstrating how to build AI applications using Amazon Bedrock's foundation models. Here's how to use each:
Image Generation
To generate images using Stable Diffusion, run the following command:
streamlit run sd_sample_st.py
This will launch a Streamlit app where you can enter text prompts to generate corresponding images.
Text Examples
Run this Python script to see different text-based applications like text summarization, code generation, and Q&A:
python text_examples.py
This script will output results for each of these applications, showcasing the versatility of foundation models in text-based tasks.
Chatbot
To interact with a chatbot built using Amazon Bedrock, LangChain, and Streamlit, run:
streamlit run chat_bedrock_st.py
This launches a Streamlit app where you can have a conversation with the chatbot, witnessing AI-powered conversational capabilities firsthand.
RAG Example
To see how Retrieval Augmented Generation (RAG) works with LangChain, execute:
python rag_example.py
This will demonstrate how RAG augments foundation models by retrieving and incorporating external data into the generated content.
Security
See CONTRIBUTING for more information.
License
This library is licensed under the MIT-0 License. See the LICENSE file.
What's inside
4 code examples (image generation, text tasks, chatbot, RAG) plus prerequisites and installation steps.
Change this for your project
- Replace
build-on-aws/amazon-bedrock-quick-startwith your own repository name - Replace
sd_sample_st.pywith your own image generation script name if different - Replace
text_examples.pywith your own text examples script name if different - Replace
chat_bedrock_st.pywith your own chatbot script name if different
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Related Documents
SUMMARY
Proposes three on-prem AI architectures, modular, hybrid, and fully local RAG, with hardware specs and vendor lists.
Retrieval & Prompts
Explains how CharMemory's extraction prompt and Vector Storage settings determine memory retrieval quality in SillyTavern.
Advanced RAG Techniques
Surveys advanced RAG architectures, Agentic, Corrective, Self-RAG, Graph RAG, RAPTOR, Multimodal, Temporal, with design trade-offs and decision guidance.
RFC-BLite: High-Performance Embedded Document Database for .NET
Specifies an embedded document database for.NET with zero-allocation I/O, C-BSON format, and ACID transactions.