Skip to main content
A knowledge base (KnowledgeBase) is an agent’s external source of knowledge — a place to store static material such as product docs, FAQs, and articles. Attach it to an agent and VeADK automatically injects a retrieval tool, so the agent retrieves relevant snippets before answering and produces more accurate, better-grounded responses (RAG).

Unified entry point: KnowledgeBase

Regardless of the backend, everything goes through the unified veadk.knowledgebase.KnowledgeBase. It selects the storage backend through backend and exposes a consistent ingestion and retrieval interface. Ingestion supports three sources:
  • From files: kb.add_from_files([...]);
  • From a directory: kb.add_from_directory("./docs");
  • From text: kb.add_from_text([...]).

Common parameters

The fields of KnowledgeBase are common to all backends:
Vector backends (local, opensearch, redis, milvus, tos_vector) embed the knowledge text and require the extensions dependency pip install "veadk-python[extensions]" plus an embedding model configured (env prefix MODEL_EMBEDDING_, falling back to MODEL_AGENT_API_KEY). viking, context_search, and openviking perform indexing on the service side, so no local embedding is needed.

Choosing a backend

Use local for debugging. For production, use managed viking, context_search, or openviking; if you already operate a vector store, choose opensearch, redis, milvus, or tos_vector.

Binding to an agent

Pass knowledgebase to Agent and the agent automatically gains a load_knowledgebase tool, deciding on its own whether to search the knowledge base when answering.

Direct retrieval

Besides automatic retrieval at agent runtime, you can call search directly for semantic search, useful for debugging or custom RAG. A top_k of 0 uses the value set at construction.
Last modified on September 19, 2026