How awslabs/genai-bedrock-agent-chatbot works
This is an EC2-focused chatbot: a user asks through the Streamlit interface, which invokes a Lambda that calls a Bedrock Agent and returns an answer with sources. The Agent handles qualitative questions through a Knowledge Base and quantitative pricing questions through an action Lambda that builds text-to-SQL queries for Athena. The README also documents Glue data preparation and OpenSearch-backed retrieval. Several deployment and integration modules are unsampled, so those relationships are shown only where the README supports them.
Main entry points: app.py Streamlit chat · invoke-lambda/index.py Agent invocation Lambda · build_query_engine.py SQL query engine · action-lambda/index.py Text-to-SQL action
Components 17
Chat interface
- Streamlit chat
code/streamlit-app/app.py - Lambda connection
code/streamlit-app/connections.py
Agent routing
- Agent invocation Lambda
code/lambdas/invoke-lambda/index.py - Bedrock Agent
Knowledge retrieval
- Bedrock Knowledge Base
- OpenSearch vector store
- EC2 guide documents
assets/knowledgebase_data_source - Vector index setup
code/lambdas/create-index-lambda/index.py
Pricing queries
- Text-to-SQL action
code/lambdas/action-lambda/index.py - SQL query engine
code/lambdas/action-lambda/build_query_engine.py - SQL and response prompts
code/lambdas/action-lambda/prompt_templates.py - Amazon Athena
Data preparation
- EC2 pricing data
assets/data_query_data_source/ec2_pricing - AWS Glue preparation
- Agent and data setup
code/lambdas/update-lambda - AWS resource definitions
code/code_stack.py
Other components
- Question asker
Connections 17
- Question asker → Streamlit chat: asks
README.md - Streamlit chat → Lambda connection: gets client
code/streamlit-app/app.py - Streamlit chat → Agent invocation Lambda: invokes
code/streamlit-app/app.py - Agent invocation Lambda → Bedrock Agent: invokes
code/lambdas/invoke-lambda/index.py - Bedrock Agent → Bedrock Knowledge Base: routes questions
README.md - Bedrock Agent → Text-to-SQL action: routes questions
README.md - Bedrock Knowledge Base → OpenSearch vector store: retrieves from
README.md - EC2 guide documents → Bedrock Knowledge Base: provides content
README.md - Vector index setup → OpenSearch vector store: creates index
README.md - Text-to-SQL action → SQL query engine: uses
README.md - SQL query engine → SQL and response prompts: uses prompts
code/lambdas/action-lambda/build_query_engine.py - SQL query engine → Amazon Athena: executes queries
code/lambdas/action-lambda/build_query_engine.py - EC2 pricing data → Amazon Athena: supplies pricing data
README.md - AWS Glue preparation → EC2 pricing data: prepares data
README.md - Agent and data setup → Bedrock Knowledge Base: syncs data
code/lambdas/update-lambda/trigger_data_source_sync.py - AWS resource definitions → Streamlit chat: defines resources
- Agent invocation Lambda → Question asker: returns answer
code/lambdas/invoke-lambda/index.py