Knowledge Bases Client
The KnowledgeBasesClient manages knowledge bases — collections of documents, sources, and configurations that agents query for context-aware responses.
zaby.knowledge_bases # → KnowledgeBasesClient
zaby . knowledgeBases ; // → KnowledgeBasesClient
Create
Unique URL-friendly identifier
Human-readable description
kb = await zaby.knowledge_bases.create({
"name" : "Product Docs" ,
"slug" : "product-docs" ,
"description" : "Company product documentation" ,
})
const kb = await zaby . knowledgeBases . create ({
name: "Product Docs" ,
slug: "product-docs" ,
description: "Company product documentation" ,
});
Documents
Upload text document
doc = await zaby.knowledge_bases.upload_text_document(kb_id, {
"text" : "Refunds are processed within 5-7 business days." ,
"metadata" : { "category" : "billing" },
})
const doc = await zaby . knowledgeBases . uploadTextDocument ( kb_id , {
text: "Refunds are processed within 5-7 business days." ,
metadata: { category: "billing" },
});
Library documents
# Create a library text document
lib_doc = await zaby.knowledge_bases.create_library_text_document({
"name" : "Company FAQ" ,
"text" : "Full FAQ content here..." ,
})
# List library documents
docs = await zaby.knowledge_bases.list_library_documents({
"limit" : 50 ,
})
# List findings for a library document
findings = await zaby.knowledge_bases.list_library_document_findings(
doc_id, { "category" : "billing" }
)
# Link a library document to a knowledge base
await zaby.knowledge_bases.link_library_document(kb_id, {
"libraryDocumentId" : lib_doc[ "id" ],
})
# Project library document sections into a KB
await zaby.knowledge_bases.project_library_document(kb_id, selection_id, {
"projection" : { ... },
})
// Create a library text document
const lib_doc = await zaby . knowledgeBases . createLibraryTextDocument ({
name: "Company FAQ" ,
text: "Full FAQ content here..." ,
});
// List library documents
const docs = await zaby . knowledgeBases . listLibraryDocuments ({
limit: 50 ,
});
// List findings for a library document
const findings = await zaby . knowledgeBases . listLibraryDocumentFindings (
doc_id , { category: "billing" }
);
// Link a library document to a knowledge base
await zaby . knowledgeBases . linkLibraryDocument ( kb_id , {
libraryDocumentId: lib_doc . id ,
});
// Project library document sections into a KB
await zaby . knowledgeBases . projectLibraryDocument ( kb_id , selection_id , {
projection: { /* ... */ },
});
Retrieval
Query the knowledge base for relevant context:
results = await zaby.knowledge_bases.retrieve(kb_id, {
"query" : "What is the refund policy?" ,
"limit" : 5 ,
})
const results = await zaby . knowledgeBases . retrieve ( kb_id , {
query: "What is the refund policy?" ,
limit: 5 ,
});
Provisional answer
Generate an answer using the KB as context:
answer = await zaby.knowledge_bases.provisional_answer(kb_id, {
"query" : "What is the refund policy?" ,
})
const answer = await zaby . knowledgeBases . provisionalAnswer ( kb_id , {
query: "What is the refund policy?" ,
});
Source groups
Organize sources into logical groups.
groups = await zaby.knowledge_bases.list_source_groups(kb_id, {
"limit" : 50 ,
})
const groups = await zaby . knowledgeBases . listSourceGroups ( kb_id , {
limit: 50 ,
});
group = await zaby.knowledge_bases.create_source_group(kb_id, {
"name" : "Billing Docs" ,
})
const group = await zaby . knowledgeBases . createSourceGroup ( kb_id , {
name: "Billing Docs" ,
});
await zaby.knowledge_bases.update_source_group(kb_id, sg_id, {
"name" : "Updated Name" ,
})
await zaby . knowledgeBases . updateSourceGroup ( kb_id , sg_id , {
name: "Updated Name" ,
});
Sources
Sources are the raw data feeds ingested into a knowledge base.
sources = await zaby.knowledge_bases.list_sources(kb_id, {
"status" : "ACTIVE" ,
})
const sources = await zaby . knowledgeBases . listSources ( kb_id , {
status: "ACTIVE" ,
});
source = await zaby.knowledge_bases.create_source(kb_id, {
"name" : "Website Crawl" ,
"type" : "web_crawl" ,
"config" : { "url" : "https://example.com/docs" },
})
const source = await zaby . knowledgeBases . createSource ( kb_id , {
name: "Website Crawl" ,
type: "web_crawl" ,
config: { url: "https://example.com/docs" },
});
await zaby.knowledge_bases.update_source(kb_id, source_id, {
"config" : { "url" : "https://new-url.com/docs" },
})
await zaby . knowledgeBases . updateSource ( kb_id , source_id , {
config: { url: "https://new-url.com/docs" },
});
await zaby.knowledge_bases.reprocess_source(kb_id, source_id)
await zaby . knowledgeBases . reprocessSource ( kb_id , source_id );
await zaby.knowledge_bases.link_source_credential(kb_id, source_id, {
"credentialId" : "cred_123" ,
})
await zaby . knowledgeBases . linkSourceCredential ( kb_id , source_id , {
credentialId: "cred_123" ,
});
Ingestion policies
Control how sources are ingested and processed.
policies = await zaby.knowledge_bases.list_ingestion_policies(kb_id)
const policies = await zaby . knowledgeBases . listIngestionPolicies ( kb_id );
policy = await zaby.knowledge_bases.create_ingestion_policy(kb_id, {
"name" : "Daily Crawl" ,
"schedule" : "0 6 * * *" ,
"sourceId" : source_id,
})
const policy = await zaby . knowledgeBases . createIngestionPolicy ( kb_id , {
name: "Daily Crawl" ,
schedule: "0 6 * * *" ,
sourceId: source_id ,
});
await zaby.knowledge_bases.update_ingestion_policy(kb_id, policy_id, {
"schedule" : "0 12 * * *" ,
})
await zaby . knowledgeBases . updateIngestionPolicy ( kb_id , policy_id , {
schedule: "0 12 * * *" ,
});
Governance policy
await zaby.knowledge_bases.upsert_governance_policy(kb_id, {
"rules" : [ ... ],
})
await zaby . knowledgeBases . upsertGovernancePolicy ( kb_id , {
rules: [ /* ... */ ],
});
Profiles
profiles = await zaby.knowledge_bases.list_profiles(kb_id)
const profiles = await zaby . knowledgeBases . listProfiles ( kb_id );
profile = await zaby.knowledge_bases.create_profile(kb_id, {
"name" : "Default" ,
"config" : { "maxChunks" : 10 },
})
const profile = await zaby . knowledgeBases . createProfile ( kb_id , {
name: "Default" ,
config: { maxChunks: 10 },
});
await zaby.knowledge_bases.update_profile(kb_id, profile_id, {
"config" : { "maxChunks" : 20 },
})
await zaby . knowledgeBases . updateProfile ( kb_id , profile_id , {
config: { maxChunks: 20 },
});
Jobs
Monitor and manage ingestion jobs.
jobs = await zaby.knowledge_bases.list_jobs(kb_id, {
"status" : "RUNNING" ,
})
const jobs = await zaby . knowledgeBases . listJobs ( kb_id , {
status: "RUNNING" ,
});
job = await zaby.knowledge_bases.get_job(kb_id, job_id)
const job = await zaby . knowledgeBases . getJob ( kb_id , job_id );
await zaby.knowledge_bases.cancel_job(kb_id, job_id)
await zaby . knowledgeBases . cancelJob ( kb_id , job_id );
Agent attachment
await zaby.agents.attach_knowledge_base(agent_id, {
"knowledgeBaseId" : kb_id,
})
await zaby . agents . attachKnowledgeBase ( agent_id , {
knowledgeBaseId: kb_id ,
});
Example
import asyncio
from zaby import Zaby
async def main ():
zaby = Zaby( api_key = "zaby_pk_..." )
kb = await zaby.knowledge_bases.create({
"name" : "Customer FAQ" ,
"slug" : "customer-faq" ,
})
await zaby.knowledge_bases.upload_text_document(kb[ "id" ], {
"text" : "Refunds are processed within 5-7 business days." ,
"metadata" : { "category" : "billing" },
})
results = await zaby.knowledge_bases.retrieve(kb[ "id" ], {
"query" : "How long do refunds take?" ,
})
print ( f "Found { len (results) } relevant results" )
await zaby.agents.attach_knowledge_base(agent_id, {
"knowledgeBaseId" : kb[ "id" ],
})
asyncio.run(main())
import { Zaby } from "@zaby-ai/sdk" ;
async function main () {
const zaby = new Zaby ({ apiKey: "zaby_pk_..." });
const kb = await zaby . knowledgeBases . create ({
name: "Customer FAQ" ,
slug: "customer-faq" ,
});
await zaby . knowledgeBases . uploadTextDocument ( kb . id , {
text: "Refunds are processed within 5-7 business days." ,
metadata: { category: "billing" },
});
const results = await zaby . knowledgeBases . retrieve ( kb . id , {
query: "How long do refunds take?" ,
});
console . log ( `Found ${ results . length } relevant results` );
await zaby . agents . attachKnowledgeBase ( agent_id , {
knowledgeBaseId: kb . id ,
});
}
main ();