Skip to content

ldmrqs/the-pilots-knowledge-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Pilots Knowledge Base

A RAG-powered chatbot that answers questions about Twenty One Pilots. Built with Pydantic AI, ChromaDB, and Streamlit, the app features "Ned" — an enthusiastic superfan persona that retrieves information from a knowledge base and responds in the voice of a true member of the Clique.

How It Works

  1. Knowledge base loading — On startup, the app reads top_kb.txt, splits it into overlapping text chunks, and embeds them using the all-MiniLM-L6-v2 sentence transformer model.
  2. Vector storage — Chunk embeddings are stored in an in-memory ChromaDB collection for similarity search.
  3. Query handling — When a user asks a question, the Pydantic AI agent embeds the query, retrieves the most relevant chunks from ChromaDB, and passes them as context to Claude (claude-sonnet-4-5) to generate an answer.
  4. Structured output — Responses are returned as structured RAGResponse objects containing the answer, source snippet, and source chunk ID.

Project Structure

├── top_kb.txt              # Knowledge base text about Twenty One Pilots
├── requirements.txt        # Python dependencies
└── src/
    ├── main.py             # Streamlit UI and app entry point
    ├── agent.py            # Pydantic AI agent with Ned's personality and RAG tool
    ├── chunker.py          # Text chunking with configurable size and overlap
    ├── embeddings.py       # Sentence transformer embedding functions
    ├── vectorstore.py      # ChromaDB collection management and similarity queries
    ├── models.py           # Pydantic models (RAGResponse)
    └── images/             # Avatar and page icon assets
        ├── ned.png
        ├── fren.jpg
        └── pagelogo.jpeg

Prerequisites

  • Python 3.12+
  • An Anthropic API key set as the ANTHROPIC_API_KEY environment variable

Setup

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Running

export ANTHROPIC_API_KEY="your-key-here"
streamlit run src/main.py

Dependencies

  • pydantic / pydantic-ai — Agent framework with structured output and tool use
  • sentence-transformers (via pydantic-ai-slim) — Local text embeddings
  • chromadb — In-memory vector store for similarity search
  • streamlit — Chat UI

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages