DVD Rental Assistant with Google Gemini + GenAI Toolbox + LlamaIndex
A modern DVD rental assistant powered by Google's Gemini AI, built with FastAPI and Streamlit. This project demonstrates the integration of Google's latest AI technology with GenAI Toolbox and LlamaIndex to create an intelligent DVD rental management system.
- Architecture
- Features
- Implementation Details
- Getting Started
- Project Structure
- API Documentation
- Author
- License
The DVD Rental Assistant follows a streamlined request flow that combines the power of Google Gemini, LlamaIndex, and GenAI Toolbox to process user queries and provide intelligent responses.
Layer | Technologies | Description |
---|---|---|
AI/ML | Google Gemini, LlamaIndex, GenAI Toolbox | LLM-driven conversational AI and tool calls |
Backend | FastAPI, PostgreSQL, WebSocket | Async API with structured DB integration |
Frontend | Streamlit, Real-time UI | Interactive, responsive user interface |
-
Google Gemini
Powers conversational AI and context-aware interactions. -
LlamaIndex
Manages conversation flow and tool orchestration. -
GenAI Toolbox
Handles secure database operations and SQL execution. -
FastAPI
Provides async API services, automatic documentation, and data validation. -
Streamlit
Enables real-time, interactive, and intuitive frontend experiences. -
Pydantic
Ensures data integrity through structured validation and serialization.
- Natural language understanding for DVD rental queries
- Real-time database operations through GenAI Toolbox
- Intelligent conversation flow with LlamaIndex
- Context-aware responses with Google Gemini
- Structured data presentation with emojis
- Smart search capabilities across film database
from toolbox_llamaindex import ToolboxClient
# Initialize toolbox client
client = ToolboxClient("http://127.0.0.1:5000")
# Load database tools
tools = client.load_toolset()
from llama_index.core.agent import AgentWorkflow
from llama_index.core.tools import ToolMetadata
from llama_index.llms import GoogleGenAI
# Initialize the agent with tools and LLM
agent = AgentWorkflow.from_tools_or_functions(
tools,
llm=GoogleGenAI(
model="gemini-1.5-pro",
vertexai_config={
"project": "vertex-ai-experminent",
"location": "us-central1"
}
),
system_prompt=DVD_RENTAL_PROMPT
)
- Python 3.9+
- PostgreSQL with Pagila database
- Google API key for Gemini
- GenAI Toolbox access
git clone https://github.com/arjunprabhulal/gemini-toolbox-dvd-rental-assistant.git
cd gemini-toolbox-dvd-rental-assistant
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your credentials:
# GOOGLE_API_KEY=your_gemini_api_key
# TOOLBOX_URL=http://127.0.0.1:5000
curl -L https://github.com/google/generative-ai-toolbox/releases/latest/download/toolbox-darwin-amd64 -o toolbox
chmod +x toolbox
./toolbox --version
This project uses the Pagila database β an example schema designed for PostgreSQL, inspired by the Sakila schema for MySQL.
Special thanks to devrimgunduz/pagila for providing the schema and sample data used in this project.
# Step 1: Create and load database
psql -U postgres
CREATE DATABASE toolbox_db;
\c toolbox_db
\q
# Step 2: Download Pagila schema and data
mkdir -p database/pagila
cd database/pagila
curl -O https://raw.githubusercontent.com/devrimgunduz/pagila/master/pagila-schema.sql
curl -O https://raw.githubusercontent.com/devrimgunduz/pagila/master/pagila-data.sql
# Step 3: Load Pagila into the toolbox_db
psql -U postgres -d toolbox_db -f pagila-schema.sql
psql -U postgres -d toolbox_db -f pagila-data.sql
# Start GenAI Toolbox
./toolbox --tools_file "dvdrental_tools.yaml"
# Start Backend
uvicorn backend:app --reload
# Start Frontend
streamlit run streamlit_app.py
Backend: http://localhost:8000
Frontend: http://localhost:8501
gemini-toolbox-dvd-rental-assistant/
βββ database/
β βββ pagila/
β βββ pagila-schema.sql # Database schema
β βββ pagila-data.sql # Initial data
β βββ pagila-insert-data.sql # Additional data
βββ backend.py # FastAPI backend
βββ streamlit_app.py # Streamlit frontend
βββ prompts.py # System prompts
βββ dvdrental_tools.yaml # Database configuration
βββ requirements.txt # Dependencies
βββ .env # Environment variables
Endpoint | Method | Description |
---|---|---|
/health |
GET | System health check |
/chat |
POST | Process user queries |
/reset-context/{user_id} |
POST | Reset user conversation context |
This project is licensed under the MIT License. See the LICENSE file for details.
For more articles on AI/ML and Generative AI, follow me on medium Arjun Prabhulal