Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt

Use this file to discover all available pages before exploring further.

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.
from xpander_sdk import KnowledgeBases

kbs = KnowledgeBases()

# Create
kb = await kbs.acreate(name="Q4 Reports", description="Quarterly earnings")

# Add documents
await kb.aadd_documents([
    "https://example.com/Q4-2024.pdf",
    "https://example.com/Q4-2025.pdf",
])

# Search
results = await kb.asearch(search_query="revenue trends", top_k=5)
for r in results:
    print(r.score, r.content[:80])

Constructor

KnowledgeBases(configuration: Optional[Configuration] = None)
ParameterTypeDefaultDescription
configurationConfigurationNoneSDK configuration. Falls back to env vars.

Module methods

MethodReturnsWhat it does
alist / listlist[KnowledgeBase]All KBs accessible to the org.
aget / getKnowledgeBaseLoad one KB by id.
acreate / createKnowledgeBaseCreate a new KB.

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.