Skip to main content

Knowledge Store API

ChromaDB-based vector storage for RAG.

KnowledgeStore

from owl.knowledge import get_knowledge_store

store = get_knowledge_store()

Methods

add_document()

Add a document to the knowledge base.

result = store.add_document(
file_path="/path/to/doc.md",
project_path="/path/to/project" # Optional
)
# {"filename": "doc.md", "chunks": 12}

Semantic search.

results = store.search(
query="authentication flow",
project_path="/path/to/project", # Optional filter
limit=3
)
# [{"text": "...", "filename": "...", "relevance": 0.85}, ...]

remove_document()

Remove a document.

removed = store.remove_document("/path/to/doc.md")
# True/False

get_stats()

Get knowledge base statistics.

stats = store.get_stats()
# {"total_chunks": 45, "sources": [...]}

list_sources()

List all document sources.

sources = store.list_sources()
# [{"filename": "doc.md", "chunks": 12, "project": "..."}, ...]

Configuration

Embedding Model

Default: nomic-embed-text

Ensure it's available:

ollama pull nomic-embed-text

Storage Location

~/.owl/knowledge/chroma/

Example Usage

from owl.knowledge import get_knowledge_store

store = get_knowledge_store()

# Add documentation
store.add_document("README.md")
store.add_document("docs/api.md")

# Search
results = store.search("how to authenticate")
for r in results:
print(f"{r['filename']}: {r['text'][:100]}...")

# Remove
store.remove_document("docs/api.md")