Skip to content

babusid/DrivePilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DrivePilot - Google Drive RAG Application

A FastAPI application that provides RAG (Retrieval-Augmented Generation) capabilities over your Google Drive files using ChromaDB vector storage and Google's Gemini AI.

Mainly built this just to get a little bit of familiarity with basic RAG architecture, nothing too fancy, but works. Plenty of potential improvements here, but not bad for a quick weekend project.

Features

  • Google OAuth2 authentication with Drive access
  • Browse and index Google Drive files and folders
  • Vector search across indexed documents
  • AI-powered chat interface using Google Gemini
  • Support for multiple file formats
    • Currently supports Google Doc, Google Slides, PDF, MS DOC/DOCX, MS PPT/PPTX, TXT
  • Chat history for contextual conversations

Prerequisites

  • Python 3.8+
  • uv package manager
  • Google Cloud Platform account
  • Google AI Studio account (for Gemini API)

Setup Guide

1. Install uv Package Manager

See the uv installation guide.

2. Clone and Setup Project

git clone [email protected]:babusid/DrivePilot.git
cd DrivePilot

Install dependencies with uv:

uv sync

3. Google Cloud Platform Setup

3.1 Create a Google Cloud Project

  1. Go to the Google Cloud Console
  2. Click "Select a project" → "New Project"
  3. Enter a project name and click "Create"

3.2 Enable Required APIs

  1. In the Google Cloud Console, go to "APIs & Services" → "Library"
  2. Search for Google Drive API
  3. Click on it, and then click enable

3.3 Create OAuth2 Credentials

  1. Go to "APIs & Services" → "Credentials" → "OAuth consent screen" (on the sidebar)
  2. Click on Get Started
  3. Enter App Name as DrivePilot and User support email as your own.
  4. Select External Audience (Internal may work properly, but has not been tested)
  5. Enter your email address in the Contact Information section
  6. Agree to the Data policy hit Continue, and then Create.
  7. In the sidebar, click Clients, and then click Create Client
  8. Select Web Application for the Application type. Name it DrivePilot.
  9. IMPORTANT Add http://localhost:8000 as a "Authorized JavaScript Origin"
  10. IMPORTANT Add http://localhost:8000/auth as an "Authorized Redirect URI"
  11. Hit create
  12. IMPORTANT Copy the Client Secret and Client ID to a safe scratchpad
  13. Recommended Download the JSON (to have a backup)
  14. Click on "Data Access" on the left sidebar, and then "Add or remove scopes"
  15. Add the following scopes:
  16. Hit Save.
  17. Click on "Audience" on the left sidebar, and then "Add users" under Test users. Add yourself (and any other google accounts that you want to test the application with.)

For more details, see the Google OAuth2 documentation.

4. Google AI Studio Setup (Gemini API)

4.1 Get Gemini API Key

  1. Go to Google AI Studio
  2. Click "Create API Key"
  3. Choose your Google Cloud project
  4. Copy the generated API key

For more information, see the Gemini API key documentation.

5. Environment Configuration

Create a .env file in the app/ directory:

cd app
cp .env.example .env 

Fill in the following environment variables to app/.env:

CLIENT_ID=your_google_client_id_here
CLIENT_SECRET=your_google_client_secret_here

# Gemini API Key
GEMINI_API_KEY=your_gemini_api_key_here

6. Run the Application

Start the FastAPI application:

cd app
uv run fastapi run

Usage

  1. Login: Navigate to http://localhost:8000 and click "Login with Google"
  2. Authorize: Grant permissions for Drive access and user info.
  3. Index Files: Browse your Google Drive files and click "Add to index" for files/folders you want to search
  4. Chat: Use the search box to ask questions about your indexed documents
  5. View History: See your conversation history in the chat window above the search box

Note: Sign in may be a little slow, this is due to initial file downloading.

Supported File Types

  • Text files (.txt)
  • PDF files (.pdf)
  • Microsoft Word documents (.docx)
  • Microsoft PowerPoint presentations (.pptx)
  • Google Docs, Slides (downloaded as .txt)

Project Structure

app/
├── main.py           # FastAPI application and routes
├── rag.py           # Vector database and RAG operations
├── gdrive.py        # Google Drive API integration
├── config.py        # Configuration management
├── logging.py       # Logging utilities
├── frontend/        # HTML templates
│   ├── home.html    # Main application interface
│   └── index.html   # Login page
└── appdata/         # Downloaded files storage

Troubleshooting

Common Issues

  1. OAuth Error: Ensure redirect URIs match exactly in Google Cloud Console
  2. API Key Error: Verify Gemini API key is set correctly in .env
  3. Permission Error: Check that required Google APIs are enabled
  4. File Download Error: Ensure your Google account has access to the files

Getting Help

About

RAG over your google drive

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published