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_documentsalist_documents/list_documentsadelete_multiple_documents/delete_multiple_documentsasearch/searchadelete/delete
Linking to an agent
Knowledge bases linked to an agent are configured in the Workbench or withagent.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
RaisesModuleException 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
RaisesModuleException 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
RaisesModuleException 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.
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.
asearch / search
Semantic search over the KB. Returns top-K matches by score.
Returns
list[KnowledgeBaseSearchResult]:
adelete / delete
Delete the entire knowledge base.
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 raiseModuleException on API failures.
