How googlecloudplatform/terraform-genai-rag works
This is an airline customer-service RAG application: users chat about airports, flights, amenities, policies, and ticket booking; the assistant invokes tools that query a separate retrieval API and may require confirmation before ticket insertion. The frontend supports three orchestration strategies, while the retrieval service exposes API routes over configurable datastore providers and embeddings. Evaluation includes golden tool-call scenarios and retrieval/response evaluation. Several runtime details are unsampled, so uncertain provider dispatch and cross-service wiring are left out rather than inferred.
Main entry points: datastore.py Datastore interface · orchestrator.py Orchestrator interface · routes.py Search and ticket routes · react_graph.py ReAct graph
Components 21
Chat frontend
- Chat routes
src/frontend_service/app.py - Assistant evaluation
src/frontend_service/evaluation/evaluation.py - Golden scenarios
src/frontend_service/evaluation/eval_golden.py
Assistant orchestration
- Orchestrator interface
src/frontend_service/orchestrator/orchestrator.py - LangChain agent
src/frontend_service/orchestrator/langchain_tools/langchain_tools_orchestrator.py - LangChain tools
src/frontend_service/orchestrator/langchain_tools/tools.py - LangGraph agent
src/frontend_service/orchestrator/langgraph/langgraph_orchestrator.py - ReAct graph
src/frontend_service/orchestrator/langgraph/react_graph.py - Graph tools
src/frontend_service/orchestrator/langgraph/tools.py - Tool execution node
src/frontend_service/orchestrator/langgraph/tool_node.py - Vertex function calling
src/frontend_service/orchestrator/vertexai_function_calling/function_calling_orchestrator.py - Function definitions
src/frontend_service/orchestrator/vertexai_function_calling/functions.py
Retrieval service
- Retrieval API
src/retrieval_service/app/app.py - Search and ticket routes
src/retrieval_service/app/routes.py
Data and storage
- Datastore interface
src/retrieval_service/datastore/datastore.py - Airline data models
src/retrieval_service/models/models.py - PostgreSQL provider
src/retrieval_service/datastore/providers/postgres.py - Cloud SQL provider
src/retrieval_service/datastore/providers/cloudsql_postgres.py - Firestore provider
src/retrieval_service/datastore/providers/firestore.py
Other components
- Customer
- Vertex embeddings
Connections 21
- Customer → Chat routes: submits chat
src/frontend_service/app.py - Chat routes → Orchestrator interface: invokes session
src/frontend_service/app.py - Orchestrator interface → LangChain agent: selects strategy
src/frontend_service/orchestrator/langchain_tools/langchain_tools_orchestrator.py - Orchestrator interface → LangGraph agent: selects strategy
src/frontend_service/orchestrator/langgraph/langgraph_orchestrator.py - Orchestrator interface → Vertex function calling: selects strategy
src/frontend_service/orchestrator/vertexai_function_calling/function_calling_orchestrator.py - LangChain agent → LangChain tools: uses tools
src/frontend_service/orchestrator/langchain_tools/langchain_tools_orchestrator.py - LangGraph agent → ReAct graph: invokes graph
src/frontend_service/orchestrator/langgraph/langgraph_orchestrator.py - ReAct graph → Graph tools: uses tools
src/frontend_service/orchestrator/langgraph/react_graph.py - ReAct graph → Tool execution node: dispatches tools
src/frontend_service/orchestrator/langgraph/react_graph.py - Vertex function calling → Function definitions: uses functions
src/frontend_service/orchestrator/vertexai_function_calling/function_calling_orchestrator.py - Assistant evaluation → Orchestrator interface: evaluates sessions
src/frontend_service/evaluation/evaluation.py - Assistant evaluation → Golden scenarios: loads scenarios
src/frontend_service/evaluation/evaluation.py - Graph tools → Search and ticket routes: requests search
src/frontend_service/orchestrator/langgraph/tools.py - Retrieval API → Search and ticket routes: registers routes
src/retrieval_service/app/app.py - Retrieval API → Datastore interface: creates datastore
src/retrieval_service/app/app.py - Search and ticket routes → Datastore interface: queries data
src/retrieval_service/app/routes.py - Search and ticket routes → Vertex embeddings: embeds query
- Datastore interface → Airline data models: uses models
src/retrieval_service/datastore/datastore.py - PostgreSQL provider → Datastore interface: implements interface
src/retrieval_service/datastore/providers/postgres.py - Cloud SQL provider → Datastore interface: implements interface
src/retrieval_service/datastore/providers/cloudsql_postgres.py - Firestore provider → Datastore interface: implements interface
src/retrieval_service/datastore/providers/firestore.py