Knowledge Base Wiki and GraphRAG (Index Governance)
Overview and use cases
Starting with 2.7.0, knowledge bases provide three types of enhanced index capabilities (Knowledge Index) on top of basic RAG: GraphRAG (entity knowledge graph), RAPTOR (summary tree), and LLM Wiki (compiling knowledge base content into maintainable canonical Wiki pages). This page covers their management surface:
Index governance: capability configuration (
index-capabilities) and asynchronous build operations (index-operations, including cancellation).Wiki content: page creation / read / update / delete, immutable versions and restoration, compiler proposal acceptance, conflict resolution, page link graph, recommendation limits, reset, and export to Memory.
GraphRAG graph browsing: graph snapshots of the active generation, entity neighbors, and community reports.
Wiki retrieval: cross-library Wiki queries and project-level Wiki search, project Wiki overview.
When to use: when knowledge base content needs to be consolidated into a structured, governable Wiki (for consumption by humans or agents), or when GraphRAG / RAPTOR is needed to enhance retrieval quality. For basic ingestion and retrieval, see Knowledge Base, Documents and Ingestion, and Retrieval and Sources.
Prerequisites
The knowledge base has been created and has ready documents (ingestion
ready); LLM-invoking capabilities (GraphRAG / RAPTOR / Wiki) require first configuring a shared Chat LLM in the knowledge baseindexingDefaults.API Key scopes:
knowledgebases.read(read / retrieval),knowledgebases.write(configure, build, write Wiki).Exporting Wiki pages to Memory requires that the current project has enabled and activated Memory (enabling Knowledge Bases does not automatically create a Memory project).
SDK surface: the enhanced index management surface is only synced to Node / Python / Go / Java Server SDK and Console (the console packages of Java / Python / Go share the same surface); Web client SDKs have no Wiki / GraphRAG / index governance methods at all.
Usage workflow
Capability configuration:
listIndexCapabilitieschecksavailable/configured/enabled/staterespectively (deployment unavailable and not enabled by the user are different signals);updateIndexCapabilitysaves the complete configuration ofgraphrag/raptor/wiki.Build: call
createIndexOperation(build/repair) with a stableidempotencyKey, pollgetIndexOperationuntil a terminal state; usecancelIndexOperationto request cancellation when needed.Wiki pages:
createWikiPagecreates a page ([[slug]]links are extracted automatically; unresolved targets are kept as red links); readgetWikiPage/listWikiPages; optimistic concurrent updateupdateWikiPage(carrying the currentcontentRevision); version historylistWikiPageRevisions/getWikiPageRevision, restorerestoreWikiPage(a historical version generates a new revision without altering history).Proposals and conflicts:
listWikiProposals/acceptWikiProposalhandle compiler proposals;listWikiConflicts/getWikiConflictProposal/resolveWikiConflicthandle conflict pages.Query:
createWikiQuery(explicit library list, 1–20 libraries) orcreateWikiProjectSearch(all libraries visible to the caller);getWikiOverviewgets the project-level Wiki status card.Graph browsing:
getWikiGraphto view the Wiki page link graph; GraphRAG usesgetGraph(text / type / community filtering orseed+hopsbounded exploration),getGraphEntityNeighbors, andlistGraphCommunityReports.Maintenance:
getWikiRecommendedLimitsgets compile limit recommendations;createWikiPageMemoryExportexports pages as Memory facts;clearIndexCapabilityclears only derived indexes;resetWikideletes the entire canonical Wiki.
Key parameters and returns
Capability identifiers
capability:graphrag/raptor/wiki; operationskind:build/repair;scope:knowledgebase/document(when the RAPTOR configuration is document-level, the operation must also bescope=documentand pass thedocumentIdsof existing active chunks; the scopes on both sides must match).Capability configuration
config: full-replacement semantics;config.languagecontrols the output language of generated content—auto(default, detected from source content) /zh/en/ja, and an explicit value overrides source language detection. The Wiki'ssourcescan be configured asrag/graphrag/memory(RAPTOR summaries are automatically enhanced withrag, which is not an independent source value).Wiki pages:
pageType∈entity/topic/survey/agent_practice/category_index;status∈draft/published/conflict/archived; write operations always carrycontentRevisionfor optimistic concurrency.Wiki query
mode:auto(default) /wiki_direct/wiki_retrieved/rag_first;topK,useVector,vectorWeight, andlinkOptions(bounded link expansion) are optional.Destructive confirmation values:
clearIndexCapabilityusesclear:<capability>,deleteWikiPageusesdelete:<slug>, andresetWikiusesreset:wiki—all three require idempotency keys;clearanddeletepreserve canonical content / revision; onlyresetWikideletes the canonical Wiki.recommended-limitsreturns recommendation values such asmax_entities/max_topics/max_surveys/rag_max_docs/rag_max_chunks_per_doc/evidence_max_chunks_to_embedandstrategy/signals;enableLlmRefine=falsereturns purely deterministic recommendations.Embedding input limit: the
maxInputTokensof the LLM Gateway Provider becomes the effective embedding input limit for Wiki projection—the indexer only truncates embedding projections and packs batches according to the limit, without modifying canonical Wiki content;nullmeans unlimited.Graph browsing is always bounded snapshots:
hasMore/nextCursorpaginate,truncated=trueindicates that only a subset is returned;hopsonly affects graph exploration and does not change the GraphRAG retrieval algorithm.
Errors and boundaries
Enabling a capability unavailable on the deployment returns
knowledge_index_capability_unavailable; disabling a capability retains existing generations and history. A temporarily unhealthy indexer does not erase stored configurations and active generations.A
contentRevisionmismatch (update / delete / restore / accept proposal / resolve conflict) means optimistic concurrency failed—re-read the page and retry.Operations are asynchronous and require idempotency keys:
force=truefirst requests cancellation of any active operation in conflict before queuing; cancellation is attempt-fenced (an old worker cannot publish results after a new attempt has taken over); poll until the terminal statessucceeded/failed/cancelled/cleared, read the operation's error on failure, and use a new idempotency key rather than retrying the same one in a loop.Conflict resolution:
resolveWikiConflictcan resolve a single conflict item (resolvedConflictId+resolvedConflictOptionText) or submit a manually merged document (contentMd); when resolving part of a proposal,proposalIdand the remainingproposalMdmust be passed to avoid unresolved portions being silently discarded.export-to-memory: returns503 memory_service_unavailablewhen the Memory service is not activated / initializing / unavailable; the response only identifies the exported Memory records and does not expose any model or Provider credentials.Cross-library queries / project search do not expose invisible libraries; capability failures of project-level Wiki search are explicitly listed in
degradedKnowledgeBases. The single-librarycreateSearchresponse usescapabilities/degradedCapabilitiesto indicate enhanced retrieval status; itsallowDegradedserver-side default istrue, falling back to basic RAG on degradable errors; passfalseexplicitly when you need an error returned immediately on failure (see Retrieval and Sources).
SDK Category Differences
Server SDK (server-sdk/nodejs.md): Node / Python / Go / Java all provide the full management surface (capability configuration, operations, Wiki pages / versions / proposals / conflicts, graph, queries); Python uses snake_case keyword arguments, Go uses positional arguments + the service method's
With*options, and Java uses positional arguments + strongly typed model returns.Client SDK (client-sdk/web.md): the Web SDK has no Wiki / GraphRAG / index governance methods at all; browser scenarios go through server-side forwarding.
Console SDK: the console packages for Java / Python / Go are isomorphic with the Server surface; the JS Console SDK's KnowledgeBases does not include these management-plane methods.
Examples by language
Each card has switchable language tabs (synchronized across the page). The Web client SDK has none of the capability surfaces on this page, so no card offers a Web tab.
Capability Configuration and Build (Including Cancellation)
First query available / configured / enabled / state, then save the graphrag (entityTypes, lexiconEnabled, graphragEmbedBatchSize, language), raptor (scope: "knowledgeBase" | "document" and GMM+BIC clustering parameters maxLevels, clusterDimension, bicThreshold, summaryTokenBudget), and wiki (await_graphrag, pageMaxConcurrent, sources) configurations respectively, and trigger the build / repair / cancel / clear operations; poll the operation until it reaches a terminal state.
- Node.js (Server)
- Java
- Python
- Go
- REST (curl)
import { Capability, Kind, Scope } from 'agentbase-node-sdk';
const caps = await kb.listIndexCapabilities({ knowledgeBaseId: base.$id });
// Check available / configured / enabled / state per item; deployment unavailable ≠ user has not enabled it
// 1. Configure GraphRAG (entity type whitelist, enable lexicon alignment lexiconEnabled, vector batch size graphragEmbedBatchSize)
await kb.updateIndexCapability({
knowledgeBaseId: 'kb_enterprise_support',
capability: Capability.Graphrag,
config: {
enabled: true,
language: 'zh',
entityTypes: ['Product', 'Component', 'ErrorCode', 'Parameter', 'SOP'],
lexiconEnabled: true,
graphragEmbedBatchSize: 32,
},
});
// 2. Configure RAPTOR (supports knowledgeBase or document granularity, plus GMM+BIC hierarchical clustering parameters)
await kb.updateIndexCapability({
knowledgeBaseId: 'kb_enterprise_support',
capability: Capability.Raptor,
config: {
enabled: true,
language: 'zh',
scope: 'knowledgeBase',
maxLevels: 3,
clusterDimension: 16,
bicThreshold: 0.15,
summaryTokenBudget: 512,
},
});
// 3. Configure LLM Wiki (enable await_graphrag and compilation concurrency pageMaxConcurrent)
await kb.updateIndexCapability({
knowledgeBaseId: base.$id,
capability: Capability.Wiki,
config: {
enabled: true,
language: 'zh',
await_graphrag: true,
pageMaxConcurrent: 4,
sources: ['rag', 'graphrag', 'memory'],
}, // Full replacement; language: auto/zh/en/ja
});
// 4. Trigger asynchronous build or repair, and poll progress or cancel (cancel)
const op = await kb.createIndexOperation({
knowledgeBaseId: base.$id,
capability: Capability.Wiki,
idempotencyKey: 'wiki-build-20260918-01', // Stable idempotency key, reused on retries
kind: Kind.Build, // Kind.Build or Kind.Repair
scope: Scope.Knowledgebase,
});
// Poll for final state succeeded / failed / cancelled / cleared
const st = await kb.getIndexOperation({ knowledgeBaseId: base.$id, operationId: op.$id });
await kb.cancelIndexOperation({ knowledgeBaseId: base.$id, operationId: '<operationId>' }); // Request cancellationimport io.agentbase.enums.Capability;
import io.agentbase.enums.Kind;
import io.agentbase.enums.Scope;
import java.util.Map;
var caps = kb.listIndexCapabilities(base.getId());
// Check available / configured / enabled / state item by item
kb.updateIndexCapability("kb_enterprise_support", Capability.GRAPHRAG,
Map.of("enabled", true, "language", "zh", "lexiconEnabled", true, "graphragEmbedBatchSize", 32,
"entityTypes", java.util.List.of("Product", "Component", "ErrorCode", "Parameter", "SOP")));
kb.updateIndexCapability("kb_enterprise_support", Capability.RAPTOR,
Map.of("enabled", true, "language", "zh", "scope", "knowledgeBase",
"maxLevels", 3, "clusterDimension", 16, "bicThreshold", 0.15, "summaryTokenBudget", 512));
kb.updateIndexCapability(base.getId(), Capability.WIKI,
Map.of("enabled", true, "language", "zh", "await_graphrag", true, "pageMaxConcurrent", 4,
"sources", java.util.List.of("rag", "graphrag"))); // Full replacement
var op = kb.createIndexOperation(base.getId(), Capability.WIKI, "wiki-build-20260918-01",
Kind.BUILD, Scope.KNOWLEDGEBASE, null, null, null, null); // documentIds / config / force / retryOf (pass retryOf when Kind.REPAIR)
var st = kb.getIndexOperation(base.getId(), op.getId()); // Poll for terminal state
kb.cancelIndexOperation(base.getId(), "<operationId>"); // Request cancellationfrom agentbase.enums.capability import Capability
from agentbase.enums.kind import Kind
from agentbase.enums.scope import Scope
caps = kb.list_index_capabilities(knowledge_base_id=base['$id'])
# Check available / configured / enabled / state item by item
kb.update_index_capability(knowledge_base_id='kb_enterprise_support', capability=Capability.GRAPHRAG,
config={'enabled': True, 'language': 'zh', 'lexiconEnabled': True, 'graphragEmbedBatchSize': 32,
'entityTypes': ['Product', 'Component', 'ErrorCode', 'Parameter', 'SOP']})
kb.update_index_capability(knowledge_base_id='kb_enterprise_support', capability=Capability.RAPTOR,
config={'enabled': True, 'language': 'zh', 'scope': 'knowledgeBase',
'maxLevels': 3, 'clusterDimension': 16, 'bicThreshold': 0.15, 'summaryTokenBudget': 512})
kb.update_index_capability(knowledge_base_id=base['$id'], capability=Capability.WIKI,
config={'enabled': True, 'language': 'zh', 'await_graphrag': True, 'pageMaxConcurrent': 4,
'sources': ['rag', 'graphrag']}) # Full replacement
op = kb.create_index_operation(knowledge_base_id=base['$id'], capability=Capability.WIKI,
idempotency_key='wiki-build-20260918-01', kind=Kind.BUILD, scope=Scope.KNOWLEDGEBASE)
st = kb.get_index_operation(knowledge_base_id=base['$id'], operation_id=op['$id']) # Poll for terminal state
kb.cancel_index_operation(knowledge_base_id=base['$id'], operation_id='<operationId>') # Request cancellationcaps, err := kb.ListIndexCapabilities(base.Id)
// Check available / configured / enabled / state item by item
_, err = kb.UpdateIndexCapability("kb_enterprise_support", "graphrag",
map[string]interface{}{"enabled": true, "language": "zh", "lexiconEnabled": true, "graphragEmbedBatchSize": 32,
"entityTypes": []string{"Product", "Component", "ErrorCode", "Parameter", "SOP"}})
_, err = kb.UpdateIndexCapability("kb_enterprise_support", "raptor",
map[string]interface{}{"enabled": true, "language": "zh", "scope": "knowledgeBase",
"maxLevels": 3, "clusterDimension": 16, "bicThreshold": 0.15, "summaryTokenBudget": 512})
_, err = kb.UpdateIndexCapability(base.Id, "wiki",
map[string]interface{}{"enabled": true, "language": "zh", "await_graphrag": true, "pageMaxConcurrent": 4,
"sources": []string{"rag", "graphrag"}}) // Full replacement
op, err := kb.CreateIndexOperation(base.Id, "wiki", "wiki-build-20260918-01",
kb.WithCreateIndexOperationKind("build"), kb.WithCreateIndexOperationScope("knowledgebase"))
st, err := kb.GetIndexOperation(base.Id, op.Id) // Poll for terminal state
_, err = kb.CancelIndexOperation(base.Id, "<operationId>") // Request cancellationcurl -sS "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/index-capabilities" \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY"
curl -sS -X PATCH "$APPBASE_ENDPOINT/knowledgebases/kb_enterprise_support/index-capabilities/graphrag" \
-H 'Content-Type: application/json' \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
-d '{"config":{"enabled":true,"language":"zh","entityTypes":["Product","Component","ErrorCode","Parameter","SOP"],"lexiconEnabled":true,"graphragEmbedBatchSize":32}}'
curl -sS -X PATCH "$APPBASE_ENDPOINT/knowledgebases/kb_enterprise_support/index-capabilities/raptor" \
-H 'Content-Type: application/json' \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
-d '{"config":{"enabled":true,"language":"zh","scope":"knowledgeBase","maxLevels":3,"clusterDimension":16,"bicThreshold":0.15,"summaryTokenBudget":512}}'
curl -sS -X PATCH "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/index-capabilities/wiki" \
-H 'Content-Type: application/json' \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
-d '{"config":{"enabled":true,"language":"zh","await_graphrag":true,"pageMaxConcurrent":4,"sources":["rag","graphrag"]}}'
# Build/repair: POST .../index-operations {"capability":"wiki","kind":"build"|"repair","scope":"knowledgebase"|"document","idempotencyKey":"..."}
# Polling: GET .../index-operations/{operationId}; Cancel: POST .../index-operations/{operationId}/cancelWiki Pages and Version Restore
Page write operations carry the current contentRevision for optimistic concurrency; every successful write produces an immutable revision, and restoring means writing a historical revision as a new revision (history is never modified).
- Node.js (Server)
- Java
- Python
- Go
- REST (curl)
import { PageType, Status } from 'agentbase-node-sdk';
const page = await kb.createWikiPage({
knowledgeBaseId: base.$id,
slug: 'refund-policy',
title: '退款政策',
pageType: PageType.Topic,
contentMd: '# 退款政策\n\n详见 [[order-lifecycle]]。', // [[slug]] automatic link extraction; unresolved targets are kept as red links
status: Status.Published,
});
const cur = await kb.getWikiPage({ knowledgeBaseId: base.$id, slug: 'refund-policy' });
await kb.updateWikiPage({
knowledgeBaseId: base.$id,
slug: 'refund-policy',
contentRevision: cur.contentRevision, // Must match the current version
page: { contentMd: '# 退款政策(v2)\n\n……' }, // Changed field set; if links/aliases are omitted they are preserved
reason: '补充跨境订单条款',
});
const revs = await kb.listWikiPageRevisions({ knowledgeBaseId: base.$id, slug: 'refund-policy' });
const latest = await kb.getWikiPage({ knowledgeBaseId: base.$id, slug: 'refund-policy' }); // Re-read to get the latest revision after updating
await kb.restoreWikiPage({
knowledgeBaseId: base.$id,
slug: 'refund-policy',
revisionId: '<revisionId>',
contentRevision: latest.contentRevision, // Restore also requires the current contentRevision fence
});
// Optional destructive operation: re-read the page before deleting to obtain the latest numeric revision.
const beforeDelete = await kb.getWikiPage({ knowledgeBaseId: base.$id, slug: 'refund-policy' });
await kb.deleteWikiPage({
knowledgeBaseId: base.$id, slug: 'refund-policy',
contentRevision: beforeDelete.contentRevision, confirmation: 'delete:refund-policy',
});import io.agentbase.enums.PageType;
import io.agentbase.enums.Status;
import java.util.Map;
var page = kb.createWikiPage(base.getId(), "refund-policy", "退款政策",
PageType.TOPIC, "# 退款政策\n\n详见 [[order-lifecycle]]。", null,
Status.PUBLISHED, null, null, null, null); // summary / pinned / links / aliases / reason
var cur = kb.getWikiPage(base.getId(), "refund-policy");
kb.updateWikiPage(base.getId(), "refund-policy", cur.getContentRevision(),
Map.of("contentMd", "# 退款政策(v2)\n\n……"), // page: set of changed fields
null, null, "补充跨境订单条款"); // links / aliases / reason
var revs = kb.listWikiPageRevisions(base.getId(), "refund-policy", 20L);
var latest = kb.getWikiPage(base.getId(), "refund-policy"); // Re-read to get the latest revision after updating
kb.restoreWikiPage(base.getId(), "refund-policy", "<revisionId>", latest.getContentRevision(), null, null);
kb.deleteWikiPage(base.getId(), "refund-policy", latest.getContentRevision(), "delete:refund-policy");from agentbase.enums.page_type import PageType
from agentbase.enums.status import Status
page = kb.create_wiki_page(knowledge_base_id=base['$id'], slug='refund-policy', title='退款政策',
page_type=PageType.TOPIC, content_md='# 退款政策\n\n详见 [[order-lifecycle]]。',
status=Status.PUBLISHED)
cur = kb.get_wiki_page(knowledge_base_id=base['$id'], slug='refund-policy')
kb.update_wiki_page(knowledge_base_id=base['$id'], slug='refund-policy',
content_revision=cur['contentRevision'], # Must match the current version
page={'contentMd': '# 退款政策(v2)\n\n……'}, # Changed field set; if links/aliases are omitted they are preserved
reason='补充跨境订单条款')
revs = kb.list_wiki_page_revisions(knowledge_base_id=base['$id'], slug='refund-policy')
latest = kb.get_wiki_page(knowledge_base_id=base['$id'], slug='refund-policy') # Re-read to get the latest revision after updating
kb.restore_wiki_page(knowledge_base_id=base['$id'], slug='refund-policy',
revision_id='<revisionId>', content_revision=latest['contentRevision'])
kb.delete_wiki_page(knowledge_base_id=base['$id'], slug='refund-policy',
content_revision=latest['contentRevision'], confirmation='delete:refund-policy')page, err := kb.CreateWikiPage(base.Id, "refund-policy", "退款政策",
kb.WithCreateWikiPagePageType("topic"),
kb.WithCreateWikiPageContentMd("# 退款政策\n\n详见 [[order-lifecycle]]。"),
kb.WithCreateWikiPageStatus("published"))
cur, err := kb.GetWikiPage(base.Id, "refund-policy")
_, err = kb.UpdateWikiPage(base.Id, "refund-policy", cur.ContentRevision,
map[string]interface{}{"contentMd": "# 退款政策(v2)\n\n……"}, // page: set of changed fields
kb.WithUpdateWikiPageReason("补充跨境订单条款"))
revs, err := kb.ListWikiPageRevisions(base.Id, "refund-policy")
latest, err := kb.GetWikiPage(base.Id, "refund-policy") // Re-read to get the latest revision after updating
_, err = kb.RestoreWikiPage(base.Id, "refund-policy", "<revisionId>", latest.ContentRevision)
_, err = kb.DeleteWikiPage(base.Id, "refund-policy", latest.ContentRevision, "delete:refund-policy")curl -sS -X POST "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/wiki/pages" \
-H 'Content-Type: application/json' \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
-d '{"slug":"refund-policy","title":"退款政策","pageType":"topic","contentMd":"# 退款政策\n\n详见 [[order-lifecycle]]。","status":"published"}'
# Update: PATCH .../wiki/pages/{slug} {"contentRevision":<n>,"page":{...},"reason":"..."}
# Versions: GET .../wiki/pages/{slug}/revisions; restore: POST .../wiki/pages/{slug}/restore {"revisionId":"...","contentRevision":<n>}
# Delete: DELETE .../wiki/pages/{slug} {"contentRevision":<n>,"confirmation":"delete:<slug>"}Proposals and Conflict Resolution
Compiler proposals are immutable revisions and do not replace the canonical content until accepted or resolved; the conflicts page lists unresolved items, which can be resolved one by one or submitted as a manual merge document.
- Node.js (Server)
- Java
- Python
- Go
- REST (curl)
// Proposal: list → accept (contentRevision prevents overwriting manually applied updates)
const proposals = await kb.listWikiProposals({ knowledgeBaseId: base.$id });
const cur = await kb.getWikiPage({ knowledgeBaseId: base.$id, slug: '<slug>' }); // CAS uses the current revision
await kb.acceptWikiProposal({
knowledgeBaseId: base.$id, proposalId: '<proposalId>', contentRevision: cur.contentRevision,
});
// Conflict: list → review the compiler's proposals → resolve individual items or submit a manual merge
const conflicts = await kb.listWikiConflicts({ knowledgeBaseId: base.$id });
const proposal = await kb.getWikiConflictProposal({ knowledgeBaseId: base.$id, slug: '<slug>' });
await kb.resolveWikiConflict({
knowledgeBaseId: base.$id,
slug: '<slug>',
contentRevision: cur.contentRevision,
resolvedConflictId: '<conflictId>', // Resolve a single conflicting item
resolvedConflictOptionText: '<chosenOption>',
// or manual merge: contentMd: '<merged markdown>'
// When part of a resolution proposal: proposalId + proposalMd (remaining content), so unresolved parts are not silently dropped
});var proposals = kb.listWikiProposals(base.getId(), 20L);
var cur = kb.getWikiPage(base.getId(), "<slug>"); // CAS uses the current revision
kb.acceptWikiProposal(base.getId(), "<proposalId>", cur.getContentRevision());
var conflicts = kb.listWikiConflicts(base.getId(), 20L, 0L);
var proposal = kb.getWikiConflictProposal(base.getId(), "<slug>");
// resolveWikiConflict(kbId, slug, contentRevision, contentMd, resolvedConflictId,
// resolvedConflictOptionText, proposalId, proposalMd, links, reason)
kb.resolveWikiConflict(base.getId(), "<slug>", cur.getContentRevision(),
null, "<conflictId>", "<chosenOption>", null, null, null, null);proposals = kb.list_wiki_proposals(knowledge_base_id=base['$id'])
cur = kb.get_wiki_page(knowledge_base_id=base['$id'], slug='<slug>') # CAS uses the current revision
kb.accept_wiki_proposal(knowledge_base_id=base['$id'], proposal_id='<proposalId>',
content_revision=cur['contentRevision'])
conflicts = kb.list_wiki_conflicts(knowledge_base_id=base['$id'])
proposal = kb.get_wiki_conflict_proposal(knowledge_base_id=base['$id'], slug='<slug>')
kb.resolve_wiki_conflict(knowledge_base_id=base['$id'], slug='<slug>',
content_revision=cur['contentRevision'],
resolved_conflict_id='<conflictId>', # Resolve a single conflicting item
resolved_conflict_option_text='<chosenOption>')
# Or manual merge: content_md='<merged markdown>'; add proposal_id + proposal_md when resolving part of a proposalproposals, err := kb.ListWikiProposals(base.Id)
cur, err := kb.GetWikiPage(base.Id, "<slug>") // CAS uses the current revision
_, err = kb.AcceptWikiProposal(base.Id, "<proposalId>", cur.ContentRevision)
conflicts, err := kb.ListWikiConflicts(base.Id)
proposal, err := kb.GetWikiConflictProposal(base.Id, "<slug>")
_, err = kb.ResolveWikiConflict(base.Id, "<slug>", cur.ContentRevision,
kb.WithResolveWikiConflictResolvedConflictId("<conflictId>"),
kb.WithResolveWikiConflictResolvedConflictOptionText("<chosenOption>"))
// Manual merge: kb.WithResolveWikiConflictContentMd(...); partial proposal: ProposalId + ProposalMdcurl -sS "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/wiki/proposals" \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY"
# Accept: POST .../wiki/proposals/{proposalId}/accept {"contentRevision":<n>}
# Conflict list: GET .../wiki/conflicts; proposal: GET .../wiki/conflicts/{slug}/proposal
# Resolve: POST .../wiki/conflicts/{slug}/resolve
# {"contentRevision":<n>,"resolvedConflictId":"...","resolvedConflictOptionText":"..."}
# or {"contentRevision":<n>,"contentMd":"<merged markdown>"}Wiki Queries and Project Search
createWikiQuery explicitly specifies 1–20 knowledge bases; createWikiProjectSearch covers all knowledge bases visible to the caller in the project; getWikiOverview returns permission-filtered project-level Wiki status cards (deployment availability, enabled status, index status, page count, and conflict count in separate columns).
- Node.js (Server)
- Java
- Python
- Go
- REST (curl)
import { Mode } from 'agentbase-node-sdk';
const overview = await kb.getWikiOverview(); // Project-level status card (no parameters)
const hits = await kb.createWikiQuery({
knowledgeBaseIds: [base.$id], // 1–20 explicit libraries
query: '退款流程是什么?',
mode: Mode.Auto, // auto / wiki_direct / wiki_retrieved / rag_first
topK: 5,
});
// Project-level search (all visible knowledge bases; capability failures are explicitly listed in degradedKnowledgeBases):
const all = await kb.createWikiProjectSearch({ query: '退款流程是什么?', mode: Mode.Auto });import io.agentbase.enums.Mode;
import java.util.List;
var overview = kb.getWikiOverview();
var hits = kb.createWikiQuery(List.of(base.getId()), "退款流程是什么?",
Mode.AUTO, 5L, null, null, null); // topK / useVector / vectorWeight / linkOptions
var all = kb.createWikiProjectSearch("退款流程是什么?", Mode.AUTO, null, null, null, null);from agentbase.enums.mode import Mode
overview = kb.get_wiki_overview() # Project-level status card (no parameters)
hits = kb.create_wiki_query(knowledge_base_ids=[base['$id']], # 1–20 explicit libraries
query='退款流程是什么?', mode=Mode.AUTO, top_k=5)
all_ = kb.create_wiki_project_search(query='退款流程是什么?', mode=Mode.AUTO)overview, err := kb.GetWikiOverview()
hits, err := kb.CreateWikiQuery([]string{base.Id}, "退款流程是什么?",
kb.WithCreateWikiQueryMode("auto"), kb.WithCreateWikiQueryTopK(5))
all, err := kb.CreateWikiProjectSearch("退款流程是什么?", kb.WithCreateWikiProjectSearchMode("auto"))curl -sS "$APPBASE_ENDPOINT/knowledgebases/wiki/overview" \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY"
curl -sS -X POST "$APPBASE_ENDPOINT/knowledgebases/wiki/query" \
-H 'Content-Type: application/json' \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
-d '{"knowledgeBaseIds":["kb_product_docs"],"query":"退款流程是什么?","mode":"auto","topK":5}'
# Project-level search: POST /knowledgebases/wiki/search {"query":"...","mode":"auto"}Knowledge Graph Browsing (Wiki Link Graph and GraphRAG)
getWikiGraph returns the canonical page link graph (redLink=true are red links); the three GraphRAG methods browse a bounded snapshot of the active generation.
- Node.js (Server)
- Java
- Python
- Go
- REST (curl)
const wikiGraph = await kb.getWikiGraph({ knowledgeBaseId: base.$id }); // canonical page + resolved/unresolved links
// GraphRAG: filter by text/type/community, or bounded exploration via seed + hops; pagination via hasMore + nextCursor, truncated=true means a subset
const graph = await kb.getGraph({ knowledgeBaseId: base.$id, seed: '<entityId>', hops: 2, limit: 50 });
const neighbors = await kb.getGraphEntityNeighbors({ knowledgeBaseId: base.$id, entityId: '<entityId>', hops: 1 });
const reports = await kb.listGraphCommunityReports({ knowledgeBaseId: base.$id, limit: 20 });var wikiGraph = kb.getWikiGraph(base.getId()); // canonical page + resolved/unresolved links
// getGraph(kbId, query, type, community, seed, hops, limit, cursor)
var graph = kb.getGraph(base.getId(), null, null, null, "<entityId>", 2L, 50L, null);
var neighbors = kb.getGraphEntityNeighbors(base.getId(), "<entityId>", 1L, null);
var reports = kb.listGraphCommunityReports(base.getId(), 20L, 0L);wiki_graph = kb.get_wiki_graph(knowledge_base_id=base['$id']) # canonical page + resolved/unresolved links
graph = kb.get_graph(knowledge_base_id=base['$id'], seed='<entityId>', hops=2, limit=50)
neighbors = kb.get_graph_entity_neighbors(knowledge_base_id=base['$id'], entity_id='<entityId>', hops=1)
reports = kb.list_graph_community_reports(knowledge_base_id=base['$id'], limit=20)wikiGraph, err := kb.GetWikiGraph(base.Id) // canonical page + resolved/unresolved links
graph, err := kb.GetGraph(base.Id, kb.WithGetGraphSeed("<entityId>"),
kb.WithGetGraphHops(2), kb.WithGetGraphLimit(50))
neighbors, err := kb.GetGraphEntityNeighbors(base.Id, "<entityId>", kb.WithGetGraphEntityNeighborsHops(1))
reports, err := kb.ListGraphCommunityReports(base.Id, kb.WithListGraphCommunityReportsLimit(20))curl -sS "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/wiki/graph" \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY"
# GraphRAG snapshot (seed + bounded hop exploration; follow nextCursor to paginate):
curl -sS --get "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/graph" \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
--data-urlencode 'seed=<entityId>' --data-urlencode 'hops=2' --data-urlencode 'limit=50'
# Neighbors: GET .../graph/entities/{entityId}/neighbors; Community reports: GET .../graph/community-reportsMaintenance (Recommended Limits / Export Memory / clear and reset)
clearIndexCapability only clears derived indexes (keeping canonical pages / links / versions / aliases); resetWiki deletes the entire canonical Wiki — the two are not the same action; the confirmation value and idempotency key are both required.
- Node.js (Server)
- Java
- Python
- Go
- REST (curl)
// Compilation limit recommendations; enableLlmRefine=false returns purely deterministic suggestions
const limits = await kb.getWikiRecommendedLimits({ knowledgeBaseId: base.$id, enableLlmRefine: false });
// Export a single page as a Memory fact (the project must have Memory activated, otherwise 503 memory_service_unavailable)
const exported = await kb.createWikiPageMemoryExport({
knowledgeBaseId: base.$id, slug: 'refund-policy', agentId: '<agentId>', // agentId is optional
});
// Only clears wiki-derived projections (canonical is preserved); confirmation value is clear:<capability>
await kb.clearIndexCapability({
knowledgeBaseId: base.$id, capability: Capability.Wiki,
confirmation: 'clear:wiki', idempotencyKey: 'clear-wiki-01',
});
// Delete the entire canonical Wiki (most destructive); confirmation value is reset:wiki
await kb.resetWiki({
knowledgeBaseId: base.$id, confirmation: 'reset:wiki', idempotencyKey: 'reset-wiki-01',
});var limits = kb.getWikiRecommendedLimits(base.getId(), false); // Purely deterministic suggestions
var exported = kb.createWikiPageMemoryExport(base.getId(), "refund-policy", "<agentId>"); // agentId may be null
kb.clearIndexCapability(base.getId(), Capability.WIKI, "clear:wiki", "clear-wiki-01"); // Only clears the projection
kb.resetWiki(base.getId(), "reset:wiki", "reset-wiki-01"); // Delete the entire canonical Wikilimits = kb.get_wiki_recommended_limits(knowledge_base_id=base['$id'], enable_llm_refine=False)
exported = kb.create_wiki_page_memory_export(knowledge_base_id=base['$id'],
slug='refund-policy', agent_id='<agentId>') # agent_id is optional; returns 503 if Memory is not activated
kb.clear_index_capability(knowledge_base_id=base['$id'], capability=Capability.WIKI,
confirmation='clear:wiki', idempotency_key='clear-wiki-01') # Only clears the projection
kb.reset_wiki(knowledge_base_id=base['$id'],
confirmation='reset:wiki', idempotency_key='reset-wiki-01') # Delete the entire canonical Wikilimits, err := kb.GetWikiRecommendedLimits(base.Id, kb.WithGetWikiRecommendedLimitsEnableLlmRefine(false))
exported, err := kb.CreateWikiPageMemoryExport(base.Id, "refund-policy",
kb.WithCreateWikiPageMemoryExportAgentId("<agentId>")) // Optional; returns 503 if Memory is not activated
_, err = kb.ClearIndexCapability(base.Id, "wiki", "clear:wiki", "clear-wiki-01") // Only clears the projection
_, err = kb.ResetWiki(base.Id, "reset:wiki", "reset-wiki-01") // Delete the entire canonical Wikicurl -sS --get "$APPBASE_ENDPOINT/knowledgebases/$KB_ID/wiki/recommended-limits" \
-H "X-Appwrite-Project: $APPBASE_PROJECT_ID" -H "X-Appwrite-Key: $APPBASE_API_KEY" \
--data-urlencode 'enableLlmRefine=false'
# Export: POST .../wiki/pages/{slug}/export-to-memory {"agentId":"..."} (Memory not activated 503)
# Clear projection: POST .../index-capabilities/wiki/clear {"confirmation":"clear:wiki","idempotencyKey":"..."}
# Reset: POST .../wiki/reset {"confirmation":"reset:wiki","idempotencyKey":"..."}Example Guide
JavaScript (complete set of Node-side Wiki / GraphRAG calls): the "Knowledge Wiki" section of examples/javascript.md.
SDK initialization and capability surface mapping for each language: server-sdk/nodejs.md, server-sdk/java.md, server-sdk/python.md, server-sdk/go.md.