Skip to content

prasanna-nagarale/QueryFoxAi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

QueryFox 🦊

Advanced RAG System with Intelligent Agentic Routing

A production-ready document intelligence system that combines Retrieval Augmented Generation (RAG) with intelligent query routing. Built with FastAPI and Streamlit, featuring automatic decision-making between local document search and real-time web search.

Python 3.11 FastAPI License: MIT


✨ Features

  • πŸ€– Intelligent Query Routing - Automatically routes between document RAG and web search using LangGraph
  • πŸ“„ Multi-Format Support - PDF, DOCX, TXT, CSV document processing
  • 🌐 Smart Web Scraping - Structured content extraction (headings, paragraphs, lists) with recursive crawling
  • πŸ” Semantic Search - FAISS vector database with K=3 retrieval optimization
  • ⚑ Fast Inference - Groq API (Llama 3.3 70B) for <2s response times
  • πŸ’¬ Interactive Chat - Real-time Streamlit interface with source attribution
  • 🐳 Docker Ready - Containerized deployment with Docker Compose

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Streamlit  β”‚ ───► β”‚  FastAPI + RAG  β”‚ ───► β”‚  Groq LLM    β”‚
β”‚   Frontend   β”‚      β”‚  + LangGraph    β”‚      β”‚  (Llama 3.3) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                   β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  FAISS   β”‚        β”‚  Tavily  β”‚
              β”‚  Vector  β”‚        β”‚  Web     β”‚
              β”‚  Search  β”‚        β”‚  Search  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Backend:

  • FastAPI - High-performance async API
  • LangChain & LangGraph - AI orchestration & agentic routing
  • FAISS - Vector similarity search
  • Groq API - Fast LLM inference
  • Tavily API - Real-time web search

Frontend:

  • Streamlit - Interactive web UI

AI/ML:

  • HuggingFace Transformers (all-MiniLM-L6-v2)
  • PyPDF, python-docx - Document processing
  • BeautifulSoup4 - Web scraping

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Docker & Docker Compose (optional)
  • Groq API Key (Get here)
  • Tavily API Key (Get here)

Local Setup (Recommended for Development)

# 1. Clone repository
git clone https://github.com/prasanna-nagarale/QueryFoxAi.git
cd QueryFox

# 2. Create environment file
cp .env.example .env
# Add your API keys to .env

# 3. Backend setup
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

# 4. Start backend (Terminal 1)
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

# 5. Frontend setup (Terminal 2)
cd ../frontend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# 6. Start frontend
streamlit run app.py

Access: http://localhost:8501


Docker Setup (Recommended for Production)

# 1. Clone and configure
git clone https://github.com/prasanna-nagarale/QueryFoxAi.git
cd QueryFox
cp .env.example .env
# Add your API keys to .env

# 2. Start with Docker
docker-compose up --build

# Access:
# Frontend: http://localhost:8501
# Backend API: http://localhost:8000/docs

πŸ“ Environment Variables

Create a .env file in the root directory:

GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here

πŸ’» Usage

1. Upload Document

  • Click "Upload Document"
  • Select PDF, DOCX, TXT, or CSV file
  • System processes and creates embeddings

2. Scrape Website

  • Enter URL in "Scrape Website"
  • Set max pages (1-5)
  • System extracts structured content

3. Ask Questions

  • Type your question in chat
  • System automatically routes to RAG or web search
  • Receive answer with source attribution

πŸ“Š Performance

  • Response Time: <2 seconds (RAG mode)
  • Document Processing: 3-7 seconds (average)
  • Retrieval Accuracy: K=3 optimized chunks
  • Supported File Size: Up to 10MB
  • Web Scraping: 1-5 pages with structured extraction

🎯 How It Works

  1. Query Analysis - LangGraph analyzes if query needs current info or can use documents
  2. Intelligent Routing:
    • RAG Path: Semantic search in FAISS β†’ Retrieve K=3 chunks β†’ Generate answer
    • Web Path: Tavily search β†’ Fetch articles β†’ Synthesize answer
  3. Response Generation - Groq LLM creates contextual answer with sources

πŸ“‚ Project Structure

QueryFox/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI application
β”‚   β”‚   β”œβ”€β”€ config.py            # Configuration
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ rag_engine.py    # RAG logic
β”‚   β”‚   β”‚   β”œβ”€β”€ langgraph_agent.py  # Agentic routing
β”‚   β”‚   β”‚   β”œβ”€β”€ document_processor.py
β”‚   β”‚   β”‚   β”œβ”€β”€ web_scraper.py
β”‚   β”‚   β”‚   └── embeddings.py
β”‚   β”‚   └── models/
β”‚   β”‚       └── schemas.py       # Pydantic models
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app.py                   # Streamlit UI
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
└── README.md

πŸ”§ API Endpoints

Endpoint Method Description
/ GET Health check
/upload POST Upload and process document
/scrape POST Scrape and process website
/query POST Query with intelligent routing
/docs GET Interactive API documentation

Full API Docs: http://localhost:8000/docs (when running)


🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments


πŸ“§ Contact

Prasanna Nagarale


🌟 Star History

If you find this project useful, please consider giving it a star ⭐


Built with ❀️ using FastAPI, LangGraph, and Groq

About

Advanced RAG System with Intelligent Agentic Routing A production-ready AI-powered document intelligence system that combines Retrieval Augmented Generation (RAG) with agentic web search routing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors