Skip to content

Ziqi418/knowledge-base-agent

Repository files navigation

Knowledge Base Agent

Personal Obsidian knowledge-base assistant built with LlamaIndex, Qdrant, DeepSeek, local BGE embeddings, and an MCP server. It indexes markdown notes, supports semantic search, optional BM25 hybrid retrieval, cross-encoder reranking, LLM answer synthesis, and a compiled summary layer for broader topic questions.

Features

  • Index Obsidian vault notes into Qdrant for vector search.
  • Query raw notes with optional folder and modified-date filters.
  • Generate note summaries and folder topic maps into the vault.
  • Ingest summaries as a second retrieval layer.
  • Expose the knowledge base to LLM agents through MCP tools in server.py.

Setup

Install Python 3.13 and uv, then install dependencies:

uv sync

Copy the example environment file and fill in your local values:

cp .env.example .env

Required settings:

  • DEEPSEEK_API_KEY: DeepSeek API key.
  • VAULT_PATH: Absolute path to your Obsidian vault.
  • QDRANT_URL: Qdrant endpoint, defaulting to http://localhost:6333.

Start Qdrant locally before indexing. For example:

docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant

Usage

Build or rebuild the raw-note index:

uv run python main.py ingest
uv run python main.py ingest --clean

Ask questions against indexed notes:

uv run python main.py query "传统 RAG 有什么局限性?"
uv run python main.py query "attention mechanism" --folder CS336
uv run python main.py query "recent ideas" --after 2025-01-01

Generate and index the summary layer:

uv run python main.py summarize
uv run python main.py summarize --dry-run
uv run python main.py summarize --since 2025-01-01
uv run python main.py summarize --folder ai
uv run python main.py ingest-summaries

Run the MCP server:

uv run python server.py

The MCP server exposes tools for querying raw notes, searching summaries, automatic query routing, reading note content, and fetching folder topic maps.

Tests

uv run pytest -v

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages