Nous.KnowledgeBase (nous v0.16.4)
View SourceLLM-compiled personal knowledge base system.
Inspired by Karpathy's vision: raw documents get ingested, an LLM compiles them into a markdown wiki with summaries, backlinks, and cross-references. You can Q&A over it, generate outputs, and run health checks.
Quick Start — Plugin Mode
Add the KB plugin to any agent for interactive use:
agent = Nous.Agent.new("openai:gpt-4",
plugins: [Nous.Plugins.KnowledgeBase],
deps: %{
kb_config: %{
store: Nous.KnowledgeBase.Store.ETS,
kb_id: "my_kb"
}
}
)
{:ok, result} = Nous.Agent.run(agent, "Ingest this article: ...")
{:ok, result} = Nous.Agent.run(agent, "What do we know about GenServers?")Quick Start — Workflow Mode
For batch operations, use the workflow API:
# Batch ingest
{:ok, state} = Nous.KnowledgeBase.ingest(
[%{title: "Article 1", content: "..."}],
kb_config: config
)
# Health check
{:ok, state} = Nous.KnowledgeBase.health_check(kb_config: config)Quick Start — Agent Behaviour Mode
For a KB-specialized agent:
agent = Nous.Agent.new("openai:gpt-4",
behaviour_module: Nous.Agents.KnowledgeBaseAgent,
plugins: [Nous.Plugins.KnowledgeBase],
deps: %{kb_config: %{store: Nous.KnowledgeBase.Store.ETS, kb_id: "my_kb"}}
)Architecture
The KB system has four composable layers:
- Data model & store —
Document,Entry,Link,HealthReportstructs with a pluggableStorebehaviour (ETS, SQLite, etc.) - Plugin & tools —
Nous.Plugins.KnowledgeBaseintegrates with any agent, providing 9 tools (search, read, ingest, add_entry, link, backlinks, list, health_check, generate) - Workflows — Pre-built DAG pipelines for ingest, incremental update, health check, and output generation
- Agent behaviour —
Nous.Agents.KnowledgeBaseAgentfor specialized KB curation and reasoning
Summary
Functions
Get backlinks for an entry.
Generate structured output from the knowledge base.
Get a specific entry by slug or ID.
Run a health check audit on the knowledge base.
Incrementally update the knowledge base with new or changed documents.
Ingest documents through the full compilation pipeline.
List all documents, optionally filtered.
List all entries, optionally filtered.
Get related entries (connected by any link direction).
Search knowledge base entries directly.
Functions
Get backlinks for an entry.
Generate structured output from the knowledge base.
Parameters
output_type-:report,:summary, or:slidesopts- Must include:kb_configand:topic
Get a specific entry by slug or ID.
Run a health check audit on the knowledge base.
Incrementally update the knowledge base with new or changed documents.
Ingest documents through the full compilation pipeline.
Options
:kb_config- Required. Knowledge base configuration map.:compiler_model- Model for compilation (default: "openai:gpt-4o-mini"):embedding- Embedding provider module:embedding_opts- Embedding options
List all documents, optionally filtered.
List all entries, optionally filtered.
Search knowledge base entries directly.