A production-ready full-stack AI application that provides a conversational interface to search files in a Google Drive folder using natural language queries.
- Frontend: Streamlit web application
- Backend: FastAPI REST API
- AI Framework: LangChain with Gemini LLM
- Cloud Services: Google Drive API with Service Account authentication
- Natural language file search in Google Drive
- Support for various search types:
- Exact file name search
- Partial file name search
- MIME type filtering
- Full-text content search
- Modified date search
- Conversational AI interface powered by Gemini
- RESTful API for easy integration
project/
├── backend/
│ ├── main.py # FastAPI application
│ ├── agent.py # LangChain agent with Gemini
│ ├── drive_service.py # Google Drive API service
│ ├── tools.py # Search tools for the agent
│ ├── prompts.py # System prompts
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment variables
├── frontend/
│ ├── app.py # Streamlit application
│ └── requirements.txt # Python dependencies
├── credentials/
│ └── service_account.json # Google Service Account key
└── README.md
- Python 3.8+
- Google Cloud Project with Drive API enabled
- Service Account with Drive API access
- Gemini API key
cd /Users/nikhilcharantimath/Desktop/mini_ai- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Drive API
- Create a Service Account:
- Go to IAM & Admin > Service Accounts
- Create a new service account
- Grant it the "Editor" role (or create a custom role with Drive read access)
- Create a JSON key and download it
- Share your Google Drive folder with the service account email
- Copy the downloaded JSON key to
credentials/service_account.json - Edit
backend/.env:- Set
GOOGLE_DRIVE_FOLDER_IDto your folder ID - Set
GEMINI_API_KEYto your Gemini API key - Adjust
HOSTandPORTif needed
- Set
cd backend
pip install -r requirements.txtcd ../frontend
pip install -r requirements.txtcd backend
python main.pyThe API will be available at http://localhost:8000
In a new terminal:
cd frontend
streamlit run app.pyThe web interface will be available at http://localhost:8501
POST /search
Content-Type: application/json
{
"query": "find all PDF files modified today"
}Response:
{
"response": "Found 3 PDF files:\n- report.pdf (Modified: 2024-01-15)\n- document.pdf (Modified: 2024-01-15)\n..."
}- "find file named 'budget.xlsx'"
- "find files containing 'meeting' in the name"
- "find all PDF files"
- "find Word documents modified today"
- "find files with 'important' in the content"
- "find recent spreadsheets"
cd backend
python -m pytest # Add tests as neededThe Streamlit app auto-reloads on code changes.
- Never commit the
credentials/service_account.jsonfile - Keep your
.envfile secure - Use environment-specific service accounts
- Regularly rotate service account keys
- "Invalid credentials": Check your service account JSON and folder sharing
- "API has not been used": Ensure Drive API is enabled in Google Cloud
- "Folder not found": Verify the
GOOGLE_DRIVE_FOLDER_IDin.env - "Gemini API error": Check your API key and quota
Check the terminal output for detailed error messages.
This project is for educational and demonstration purposes.