A powerful, modern AI-powered document analysis and chat application built with FastAPI, featuring Retrieval-Augmented Generation (RAG), web search capabilities, and a beautiful responsive UI.
- RAG (Retrieval-Augmented Generation): Upload documents and ask questions with AI-generated answers based on your content
- Multi-format Support: PDF, DOCX, and TXT file processing
- Smart Chunking: Intelligent document segmentation with overlap for better context
- Semantic Search: Find relevant information using vector embeddings
- Person Search: Automatically search the web for information about people
- Real-time Information: Get current information from multiple web sources
- Hybrid Responses: Combine document knowledge with web information
- Responsive Design: Beautiful, modern UI that works on all devices
- Dark/Light Mode: Toggle between themes with persistent preferences
- Drag & Drop: Intuitive file upload with visual feedback
- Real-time Status: Live system status indicators
- Smooth Animations: Professional animations and transitions
- Vector Database: Milvus Managed (Zilliz Cloud) for scalable vector storage
- OpenAI Integration: GPT-3.5-Turbo for intelligent responses
- RESTful API: Clean, well-documented API endpoints
- Error Handling: Comprehensive error handling and user feedback
- Python 3.8 or higher
- OpenAI API key
- Milvus Managed (Zilliz Cloud) account
-
Clone the repository
git clone <your-repo-url> cd fastapi-vibe-coding
-
Create and activate virtual environment
python -m venv myenv source myenv/bin/activate # On Windows: myenv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
export OPENAI_API_KEY="your-openai-api-key-here"
-
Test OpenAI connection (optional but recommended)
python test_openai.py
-
Update Milvus configuration (in
main.py)MILVUS_URI = "your-milvus-uri" MILVUS_TOKEN = "your-milvus-token" COLLECTION_NAME = "your-collection-name"
-
Run the application
python main.py
-
Open your browser Navigate to
http://localhost:8000to access the beautiful web interface!
POST /ask
Content-Type: application/json
{
"message": "What is this document about?"
}- RAG + Web Search: Combines document context with web information
- Smart Person Detection: Automatically searches web for person-related queries
- AI Synthesis: Uses GPT-3.5-Turbo for intelligent responses
POST /upload-document
Content-Type: multipart/form-data
file: [PDF/DOCX/TXT file]- Multi-format Support: PDF, DOCX, TXT files
- Automatic Processing: Chunking, embedding, and storage
- Real-time Feedback: Upload progress and status updates
POST /web-search
Content-Type: application/json
{
"query": "search term"
}- Direct Web Search: Search the web for any topic
- Content Extraction: Parse and extract relevant information
- Formatted Results: Clean, structured search results
POST /add-document-string
Content-Type: application/json
{
"text": "Your text content here...",
"document_name": "Optional Name"
}GET /api/hello
GET /test-ai
GET /api/status
POST /api/reinitialize-openai- Health Checks: API and AI system status
- Testing: Verify AI functionality
- Status Monitoring: Comprehensive system status
- Reinitialization: Reinitialize OpenAI client if needed
- Modern UI: Responsive design with CSS Grid and Flexbox
- JavaScript: Vanilla JS with modern ES6+ features
- Font Awesome: Professional icons throughout
- Inter Font: Clean, modern typography
- FastAPI: High-performance Python web framework
- Pydantic: Data validation and serialization
- Async/Await: Non-blocking I/O operations
- CORS: Cross-origin resource sharing enabled
- OpenAI GPT-3.5-Turbo: Natural language processing
- OpenAI Embeddings: Text vectorization (Ada-002)
- Milvus Vector DB: Scalable vector storage and search
- Google Search: Web information retrieval
- PyPDF2: PDF text extraction
- python-docx: DOCX file processing
- BeautifulSoup: Web content parsing
- Chunking Algorithm: Intelligent text segmentation
- Research Papers: Extract key insights and answer questions
- Reports: Analyze business reports and generate summaries
- Manuals: Get quick answers from technical documentation
- Books: Interactive reading with AI-powered insights
- Professional Profiles: Get information about people
- Background Checks: Research individuals and their work
- Networking: Learn about contacts and connections
- Biographical Data: Historical and current information
- Web Search: Find current information on any topic
- Fact Checking: Verify information from multiple sources
- Research: Gather information for projects and studies
- Learning: Interactive learning with AI assistance
OPENAI_API_KEY=sk-your-openai-api-keyMILVUS_URI = "https://your-cluster.zillizcloud.com"
MILVUS_TOKEN = "your-milvus-token"
COLLECTION_NAME = "your-collection-name"
DIMENSION = 3270 # OpenAI Ada embedding dimension- Chunk Size: Adjust document chunking parameters
- Search Results: Configure number of web search results
- AI Model: Switch between different OpenAI models
- UI Theme: Customize colors and styling
- Modern chat interface with document upload
- Real-time status indicators
- Dark/light mode toggle
- Responsive design for all devices
- Drag & drop file upload
- Progress indicators
- Success/error feedback
- Document information display
- Message history with timestamps
- Typing indicators
- Rich text responses
- Context-aware answers
-
Test your API key:
python test_openai.py
-
Check environment variable:
echo $OPENAI_API_KEY
-
Common issues:
- Invalid API key: Ensure your key starts with
sk-and is correct - No credits: Check your OpenAI account billing
- Rate limits: Wait a moment and try again
- Network issues: Check your internet connection
- Invalid API key: Ensure your key starts with
-
Reinitialize OpenAI client:
curl -X POST http://localhost:8000/api/reinitialize-openai
- Check configuration in
main.py - Verify credentials are correct
- Ensure collection exists or can be created
- Check network connectivity to Zilliz Cloud
- Port conflicts: Change port in
main.pyif 8000 is busy - Dependencies: Ensure all packages are installed correctly
- File permissions: Check write permissions for uploads
fastapi-vibe-coding/
βββ main.py # FastAPI application
βββ requirements.txt # Python dependencies
βββ static/
β βββ index.html # Modern web interface
βββ myenv/ # Virtual environment
βββ README.md # This file
- FastAPI: Web framework
- Uvicorn: ASGI server
- OpenAI: AI model integration
- PyMilvus: Vector database client
- BeautifulSoup: Web scraping
- Font Awesome: Icons
# Enable auto-reload
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Or use the built-in runner
python main.py- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI for the excellent web framework
- OpenAI for powerful AI models
- Milvus for scalable vector storage
- Font Awesome for beautiful icons
- Inter Font for modern typography
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]