Skip to main content
The KnowledgeBases module is the entry point for managing knowledge bases: vector stores backed by uploaded documents. Use it to list existing KBs, load one, or create a new KB. The actual document operations (add_documents, search, list_documents, delete) live on the KnowledgeBase instance.

Constructor

Module methods

KnowledgeBase instance methods

See the KnowledgeBase class reference for:
  • aadd_documents / add_documents
  • alist_documents / list_documents
  • adelete_multiple_documents / delete_multiple_documents
  • asearch / search
  • adelete / delete

Linking to an agent

Knowledge bases linked to an agent are configured in the Workbench or with agent.attach_knowledge_base(...). Once linked, the agent’s framework retriever queries them automatically: see the Agent knowledge bases page.

create

KnowledgeBases.acreate provisions a new managed knowledge base. The returned KnowledgeBase is empty until you aadd_documents(...) to populate it.

Parameters

Returns KnowledgeBase

A new KnowledgeBase with total_documents=0. Use kb.aadd_documents([...]) to populate it.

Examples

Create + populate

aadd_documents accepts a list of URLs the platform fetches and ingests. See the KnowledgeBase reference.

Sync version

Errors

Raises ModuleException on failure.

get

KnowledgeBases.aget loads one knowledge base by id, returning a full KnowledgeBase instance.

Parameters

Returns KnowledgeBase

A full KnowledgeBase instance. See the KnowledgeBase class reference.

Sync version

Errors

Raises ModuleException on failure:

list

KnowledgeBases.alist returns every knowledge base your organization owns.

Parameters

None.

Returns list[KnowledgeBase]

Each KnowledgeBase is a full instance. See the KnowledgeBase class reference for fields and methods.

Sync version

Errors

Raises ModuleException on failure.

KnowledgeBase class

KnowledgeBase is the instance you get back from KnowledgeBases.aget, acreate, or alist. It carries the KB metadata and the methods to populate, query, and tear it down.

Attributes

Methods

aadd_documents / add_documents

Upload documents by URL. The platform fetches the URLs, chunks the content, embeds it, and indexes the embeddings.
Returns list[KnowledgeBaseDocumentItem]: one entry per uploaded document with the platform-assigned id and the document_url.

alist_documents / list_documents

List all documents in the KB.
Returns list[KnowledgeBaseDocumentItem]. KnowledgeBaseDocumentItem fields:

adelete_multiple_documents / delete_multiple_documents

Delete documents by id.
To delete a single document, you can also call await doc.delete() on a KnowledgeBaseDocumentItem returned by alist_documents. Semantic search over the KB. Returns top-K matches by score.
Returns list[KnowledgeBaseSearchResult]:

adelete / delete

Delete the entire knowledge base.
This is irreversible. The KB and all its documents are removed.

Examples

Bulk-add and verify

Search with context

use_bubble=True is great for human-readable snippets; for embedding into LLM prompts, the default False (chunk-only) is usually enough.

Reindex (delete + re-add)

sync=True blocks until reindexing finishes, so the KB is queryable when the call returns.

Errors

All KB methods raise ModuleException on API failures.