AI-Powered RAG Chat Agent (Coffee Barista)
RAG Chat Agent : An AI-powered conversational agent
In the rapidly evolving landscape of artificial intelligence, the ability to build production-ready, context-aware conversational agents has become a critical skill. The AI-powered Coffee Barista project demonstrates exactly how to accomplish this, using Google's Agent Development Kit (ADK), Gemini, and Vertex AI to create an intelligent agent that provides personalized recommendations from structured data sources . This reference architecture showcases how to combine Retrieval-Augmented Generation (RAG), agent frameworks, and cloud deployment into a cohesive, functional application.
The Vision: From Simple Chat to Intelligent Agent
The Coffee Barista represents a paradigm shift in how we think about conversational AI. Rather than a simple chatbot that generates generic responses, this agent is context-aware, data-grounded, and respectful of user constraints. Built as part of the Google Gen AI Academy's "Build and Deploy a Streamlit RAG Agent with Google ADK and Cloud Run" lab, the project serves as both a learning exercise and a practical template for building domain-specific AI agents.
The core concept is elegant: an AI-powered barista that recommends coffee and pastries based on actual menu data, while intelligently respecting dietary preferences like dairy-free requests. The agent doesn't hallucinate or guess—it retrieves real menu information and bases its recommendations on verified data.
Core Architecture and Technology Stack
The Google ADK Foundation
At the heart of the Coffee Barista lies the Google Agent Development Kit (ADK) , a powerful framework for building and orchestrating AI agents . The ADK provides a structured approach to agent development, handling the complexities of tool binding, state management, and multi-agent orchestration . The agent is defined in just a few lines of Python, with the ADK managing the heavy lifting:
python:
from google.adk.agents import Agent
from google.adk.tools.retrieval.vertex_ai_rag_retrieval import VertexAiRagRetrieval
from vertexai.preview import rag
root_agent = Agent(
model="gemini-2.0-flash-001",
name="ask_rag_agent",
instruction=return_instructions_root(),
tools=[ask_vertex_retrieval],
)
This simplicity is a hallmark of the ADK approach—production-ready agents can be built in less than 100 lines of Python.
Gemini and Vertex AI Integration
The agent leverages Gemini through Vertex AI, Google's enterprise-grade AI platform . This integration provides:
- Managed LLM Access: The Gemini model handles natural language understanding and generation
- Enterprise Security: IAM service accounts with minimal permissions ensure security (roles: aiplatform.user)
- Scalability: Vertex AI handles the computational demands of LLM inference
Retrieval-Augmented Generation (RAG)
RAG is the secret sauce that makes the Coffee Barista intelligent and reliable. Instead of relying on the LLM's internal knowledge (which might be outdated or incorrect), the agent retrieves relevant information from a structured data source.
The RAG implementation uses the VertexAiRagRetrieval tool, which connects to a RAG corpus stored in Vertex AI :
python:
ask_vertex_retrieval = VertexAiRagRetrieval(
name="retrieve_rag_documentation",
description="Use this tool to retrieve documentation...",
rag_resources=[rag.RagResource(rag_corpus=os.environ.get("RAG_CORPUS"))],
similarity_top_k=10,
vector_distance_threshold=0.6,
)
This approach ensures that every recommendation is grounded in actual menu data—no hallucinations, no made-up items.
Streamlit Chat Interface
The user interface is built with Streamlit, a Python framework that makes creating data applications simple and intuitive . The chat interface provides:
- Interactive conversation with the AI Barista
- Clear display of recommendations
- Visual feedback for user queries
Google Cloud Run Deployment
The application is deployed on Google Cloud Run, a serverless platform that automatically scales to handle demand . The deployment process is streamlined using Cloud Build:
bash:
gcloud run deploy coffee-barista \
--source . \
--region $REGION \
--allow-unauthenticated \
--service-account "barista-agent-sa@$PROJECT_ID.iam.gserviceaccount.com" \
--set-env-vars GOOGLE_GENAI_USE_VERTEXAI=TRUE,GOOGLE_CLOUD_PROJECT=$PROJECT_ID
This serverless approach means the application scales from zero to N automatically, with pay-per-use pricing—perfect for prototypes and production applications alike.
How the RAG Agent Works
Data Ingestion
The menu data is stored in a structured JSON file, containing items with their attributes—names, descriptions, dietary tags (like "dairy-free"), and pricing information . This structured format makes it easy to query and filter:
json:
{
"items": [
{
"name": "Oat Milk Latte",
"description": "Smooth espresso with creamy oat milk",
"dairy_free": true,
"category": "coffee"
},
{
"name": "Croissant",
"description": "Buttery, flaky pastry",
"dairy_free": false,
"category": "pastry"
}
]
}
Query Processing Flow
- User Query: A user asks, "I'm lactose intolerant. What can I drink?"
- RAG Retrieval: The agent uses the VertexAiRagRetrieval tool to query the menu corpus for relevant items
- Context Augmentation: The retrieved menu items are added to the prompt, providing grounded context
- Constraint Application: The agent applies dietary filters based on the user's stated needs
- Response Generation: Gemini generates a response based solely on the augmented context
Testing the RAG Behavior
The Google Codelab demonstrates three key test scenarios :
- In-Menu Verification: "Recommend something strong and warm" → The agent recommends Espresso
- Out-of-Menu Traps: "Do you have a Matcha Frappuccino?" → The agent politely declines, stating it's not on the menu
- Allergen-Aware Recommendations: "I'm lactose intolerant" → The agent recommends dairy-free items only
Production-Ready Features
Security and IAM
The deployment follows the principle of least privilege . A dedicated service account (barista-agent-sa) is created with only the roles/aiplatform.user role, ensuring the application has exactly the access it needs—no more, no less. This is critical for production applications where security vulnerabilities could otherwise expose sensitive cloud resources.
Deployment Architecture
The application architecture follows a clean separation of concerns :
- Frontend Service: Streamlit chat interface running on Cloud Run
- Backend Service: Agent orchestration via ADK and Vertex AI
- RAG Engine: Managed retrieval from the Vertex AI RAG corpus
- IAM: Fine-grained service accounts with minimal permissions
Monitoring and Observability
Cloud Run's built-in observability stack provides automatic logging, metrics, and tracing . This includes:
- Cloud Logging: All agent activity, errors, and performance data
- Cloud Run Metrics: Request counts, latency, instance count, memory/CPU utilization
- Error Reporting: Automatic grouping of recurring issues
- Cloud Trace: End-to-end request timelines
User Benefits
Immediate, Grounded Intelligence
The Coffee Barista demonstrates how RAG transforms AI from a general-purpose chatbot to a domain-specific expert. Every recommendation is grounded in real data, eliminating hallucinations and ensuring accuracy .
Educational Value
The project serves as a complete reference architecture for building RAG agents. It shows developers how to :
- Build agents using Google ADK
- Implement RAG with Vertex AI
- Create Streamlit UIs
- Deploy to Cloud Run with security and scalability
Adaptability
While the Coffee Barista is a specific use case, the architecture is highly adaptable . The same pattern can be applied to:
- E-commerce: Product recommendation engines with inventory awareness
- Customer Support: Knowledge base Q&A with up-to-date documentation
- Education: Domain-specific tutoring with verified content
- Healthcare: Patient information with medical references
Future Directions
The Coffee Barista project points toward exciting possibilities for RAG agents :
- Firestore Integration: Dynamic data sources that update in real-time
- Vector Search: More sophisticated retrieval with semantic understanding
- User Authentication: Personalized recommendations based on user history
- Conversation Memory: Contextual awareness across sessions
- Voice Assistant: Natural language interfaces for real-world interactions
- Online Ordering: End-to-end e-commerce integration
Conclusion
The AI-Powered Coffee Barista project demonstrates the power of modern AI agent frameworks. By combining Google ADK, Gemini, Vertex AI, Streamlit, and Cloud Run, it creates a production-ready RAG agent that provides intelligent, grounded, and context-aware recommendations.
The architecture is a blueprint for building enterprise-grade AI agents across any domain. It shows how to :
- Build: Create an agent using ADK's simple, Pythonic API
- Ground: Implement RAG with Vertex AI for accurate, data-backed responses
- Deploy: Use Cloud Run for scalable, serverless hosting
- Secure: Apply IAM least-privilege principles for production safety
- Monitor: Leverage GCP's built-in observability stack
The Coffee Barista is more than a fun demo—it's a template for the future of intelligent, domain-specific applications. Whether you're building a product recommendation engine, a customer support agent, or an educational tool, this architecture provides a proven path from concept to production.
