Skip to content

vyom-modi/KNOT

Repository files navigation

KNOT 🪢

Knowledge Network & Ontology Tracker

KNOT is an AI-powered observability and reasoning tool that transforms unstructured text (PDFs, CSVs, Slack exports) into a traversable Knowledge Graph. It allows you to visualize entities and relationships, and uses an autonomous agent to perform complex computational reasoning over your data.

License: MIT React FastAPI Python

KNOT Home Page


✨ Features

  • PydanticAI Extraction (The "Gatekeeper"): Robustly converts messy, unstructured files (PDF, TXT, CSV, JSON) into strictly typed Pydantic models (Entities and Relationships) using the Groq API.
  • Auto-Retry Validation: If the LLM hullucinates or misses required fields (like source_citation), the Gatekeeper automatically prompts the LLM to correct itself.
  • Interactive Knowledge Visualization: Smooth, responsive 2D Force Graph to visualize project ontologies, featuring smart zooming, node coloring by type, and connection highlighting.
  • Smart Query Routing:
    • Fast Path: Direct LLM context injection for simple queries (Who, What, When).
    • Complex Path: Autonomous SmolAgents CodeAgent (The "Weaver") that writes Python code to compute centrality, graph overlaps, and shortest paths.
  • Grounding Evidence: Every query response explicitly highlights the exact nodes in the graph that were used to formulate the answer.
  • Supabase Persistence: Fully backed by PostgreSQL for projects, documents, entities, relationships, and chat histories.

🏗️ Architecture Stack

┌─────────────────────────────────┐           HTTP/REST           ┌─────────────────────────────────┐
│         React Frontend          │ ────────────────────────────► │         FastAPI Backend         │
│         (Vite + TW4)            │ ◄──────────────────────────── │      (Python 3.13, Uvicorn)     │
│                                 │                               │                                 │
│  • Project Sidebar              │                               │  • /api/projects (CRUD)         │
│  • Chat UI                      │                               │  • /api/upload (Parsers)        │
│  • 2D Force Graph (Viz)         │                               │  • /api/query (Agents/LLM)      │
│  • Grounding Evidence Pane      │                               │  • /api/graph (Nodes/Edges)     │
└─────────────────────────────────┘                               └─────────────┬───────────────────┘
                                                                                │
                                           ┌────────────────────────────────────┼───────────────────────────┐
                                           │                                    │                           │
                                           ▼                                    │                           ▼
                            ┌──────────────────────────────┐                    │            ┌─────────────────────────────┐
                            │    Supabase (PostgreSQL)     │                    │            │        Groq LLM API         │
                            │                              │                    │            │      (llama-3.3-70b)        │
                            │  • projects     • entities   │                    │            │                             │
                            │  • documents    • relations  │                    │            │  • PydanticAI Extraction    │
                            │  • messages                  │                    │            │  • SmolAgents Reasoning     │
                            └──────────────────────────────┘                    │            └─────────────────────────────┘
                                                                                │
                                                                                ▼
                                                                  ┌───────────────────────────┐
                                                                  │      The "Gatekeeper"     │
                                                                  │  (Structured Extraction)  │
                                                                  ├───────────────────────────┤
                                                                  │       The "Weaver"        │
                                                                  │   (Graph Query/Analysis)  │
                                                                  └───────────────────────────┘
  • Frontend: React 19, Vite, Tailwind CSS (v4), Framer Motion, React Force Graph 2D, Lucide Icons.
  • Backend: FastAPI (Python 3.13), Uvicorn.
  • Database: Supabase (PostgreSQL).
  • AI & Reasoning:
    • Groq API (Llama 3.3 70B Versatile) for high-speed inference.
    • PydanticAI for type-safe data extraction.
    • SmolAgents (HuggingFace) for CodeAgent reasoning.

🚀 Getting Started

Prerequisites

  • Node.js 18+
  • Python 3.13+
  • Supabase account (Free tier)
  • Groq API Key (Free tier)

1. Database Setup (Supabase)

  1. Create a new project in your Supabase Dashboard.
  2. Go to the SQL Editor.
  3. Copy the contents of python_backend/create_tables.sql.
  4. Run the SQL script to generate the required tables (projects, documents, entities, relationships, messages).

2. Backend Setup

cd python_backend

# Create a virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure Environment Variables
cp .env.example .env
# Edit .env and add your GROQ_API_KEY, SUPABASE_URL, and SUPABASE_KEY

# Start the FastAPI server
python main.py

The backend will run on http://localhost:8000.

3. Frontend Setup

Open a new terminal window:

# Return to root directory
cd ..

# Install dependencies
npm install

# Start the development server
npm run dev

The frontend will run on http://localhost:3000.


💡 Usage Guide

  1. Create a Project: Click "New Project" in the sidebar to create a dedicated sandbox.
  2. Upload Data: Click the "Upload" button (☁️) in the chat header. Select a PDF, CSV, TXT, or JSON file. The system will slice it, extract entities via PydanticAI, and populate the graph.
  3. Explore the Graph: Drag nodes, zoom in/out. Nodes are color-coded by their ontological category (Person, Technology, Location, etc.).
  4. Chat & Reason:
    • Ask simple questions: "Who is participating in the project?" (Uses direct LLM routing for speed).
    • Ask complex questions: "Which entities have the most overlap?" or "What is the shortest path between Node A and Node B?" (Triggers the SmolAgent to write and execute analytical Python code).
  5. Inspect Grounding: Click on the highlighted "Grounding Evidence" pills below an agent response to watch the graph auto-zoom and illuminate the exact data points referenced.

📄 License

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

About

KNOT is an AI-powered observability and reasoning tool that transforms unstructured text (PDFs, CSVs, Slack exports) into a traversable Knowledge Graph. It allows you to visualize entities and relationships, and uses an autonomous agent to perform complex computational reasoning over your data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors