Files
2026-09-08 11:00:05 +05:30
..
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30
2026-09-08 11:00:05 +05:30

Chatbot Module

This module implements a robust, conversational RAG (Retrieval-Augmented Generation) chatbot for documents, integrated into the DocQube application.

📂 Structure

  • engine/: The core RAG orchestration logic (using LlamaIndex and custom adapters).
    • chatbot_engine.py: Main orchestrator handling intent, memory, and path selection.
    • intent.py: Heuristic and LLM-based intent classification.
    • retrieval.py: Qdrant-based retrieval pipeline.
    • rewrite.py: Context-aware query rewriting.
    • prompts.py: Expertly engineered RAG and intent prompts.
    • formatter.py: Dynamic response formatting logic.
  • services/: Integration services.
    • chat_service.py: FastAPI service layer managing session engines and streaming.
  • models/: SQLAlchemy and Pydantic models for chat data.
  • routes/: FastAPI endpoint definitions.

🏗️ Architecture

User Query → Intent Detection → Query Rewrite → Retrieval → LLM (DeepSeek) → Streaming Response
  • LLM: DeepSeek Chat (via OpenAI-compatible adapter).
  • Vector DB: Qdrant (integrated via LlamaIndex/Custom pipeline).
  • Embeddings: BAAI/bge-base-en-v1.5 for semantic search.

⚙️ Configuration

  • DeepSeek API: Requires DEEPSEEK_API_KEY in .env.
  • Vector Store: Qdrant must be running (configured via docker-compose).
  • Persistence: Engine indices are cached per-document for performance.

🚀 Endpoints

  • POST /api/chat/upload: Upload a document for analysis.
  • POST /api/chat/chat: Synchronous chat response.
  • GET /api/chat/stream: Streaming chat response (Server-Sent Events).
  • GET /api/chat/documents: List uploaded documents.
  • DELETE /api/chat/documents/{id}: Delete a document and its indices.