Skip to content

SihanUdayaratna03/DocSense-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocSense AI

DocSense AI is an advanced agentic system powered by LlamaIndex and Google Gemini (gemini-2.0-flash). It processes, indexes, and queries complex PDF documents using Retrieval-Augmented Generation (RAG) while persisting session records dynamically via local tool integration.

System Architecture

graph TD
    User([User CLI]) -->|Queries| Agent[ReAct Agent]
    Agent -->|1. Route Request| Router{Tool Router}
    Router -->|If PDF Query| RAG[LlamaIndex Query Engine]
    Router -->|If Note Saving| Notes[Note Saver Tool]
    RAG -->|Retrieve Context| Storage[(Vector Store Index)]
    Storage -.->|Token Chunking| PDF[Sri_Lanka.pdf]
    RAG -->|Generate Answer| LLM[Google Gemini 2.0]
    Notes -->|Write Notes| File[data/notes.txt]
    LLM -->|Answer| Agent
    Agent -->|Final Output| User

    %% Styles with high contrast dark text for dark-mode safety
    style User fill:#e1f5fe,stroke:#01579b,stroke-width:2px,color:#0a2540
    style Agent fill:#ede7f6,stroke:#4a148c,stroke-width:2px,color:#0a2540
    style Router fill:#fff3e0,stroke:#e65100,stroke-width:2px,color:#0a2540
    style RAG fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px,color:#0a2540
    style Notes fill:#fbe9e7,stroke:#bf360c,stroke-width:2px,color:#0a2540
    style Storage fill:#e8eaf6,stroke:#1a237e,stroke-width:2px,color:#0a2540
    style PDF fill:#fce4ec,stroke:#880e4f,stroke-width:2px,color:#0a2540
    style LLM fill:#e0f2f1,stroke:#004d40,stroke-width:2px,color:#0a2540
    style File fill:#efebe9,stroke:#3e2723,stroke-width:2px,color:#0a2540
Loading

Core Features

  • Intelligent ReAct Agent: Autonomously determines whether to consult knowledge bases or execute procedural tools (e.g. saving summaries).
  • API Rate-Limit Optimizer: Special token-splitting batch loader with custom delay buffers to respect free-tier API quotas (bypasses Gemini 429 Resource Exhausted errors).
  • Persistent Vector Indexing: Caches document vectors locally to guarantee instantaneous search on subsequent runs.

Technical Details

  • Knowledge Source: The RAG context is populated from a comprehensive PDF handbook containing geographic, cultural, and political profiles of Sri Lanka.
  • Local Notes Persistence: Integrates a note_saver FunctionTool to record session logs directly into data/notes.txt on command.
  • Adaptive API Throttling: Embeds nodes using the new gemini-embedding-2 model in 5-node batches, with 3-second intervals and an automatic 60-second recovery timeout block. This prevents API lockouts on Google's free tier (15 requests per minute limit).
  • Model Configurations:
    • LLM: gemini-2.0-flash (via google-genai unified SDK)
    • Embeddings: gemini-embedding-2

Getting Started

Prerequisites

Ensure you have Python 3.10+ installed.

Installation & Setup

  1. Clone the repository:

    git clone https://github.com/SihanUdayaratna03/DocSense-AI.git
    cd DocSense-AI
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure Environment: Create a .env file in the root folder:

    GEMINI_API_KEY=your_gemini_api_key_here
  4. Launch Agent:

    python main.py

About

DocSense AI is an advanced agentic system powered by LlamaIndex and Google Gemini (gemini-2.0-flash). It processes, indexes, and queries complex PDF documents using Retrieval-Augmented Generation (RAG) while persisting session records dynamically via local tool integration.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors