ObjectStackObjectStack

Knowledge Document

Knowledge Document protocol schemas

Knowledge Document / Chunk / Hit — canonical shapes shared by every

IKnowledgeAdapter implementation.

The framework does not prescribe chunk strategy or vector

format. Adapters are free to chunk however they like; the framework

only requires they round-trip these shapes when talking to the

IKnowledgeService.

See content/docs/protocol/knowledge.mdx for the full design.

Source: packages/spec/src/ai/knowledge-document.zod.ts

TypeScript Usage

import { KnowledgeChunk, KnowledgeDocument, KnowledgeHit } from '@objectstack/spec/ai';
import type { KnowledgeChunk, KnowledgeDocument, KnowledgeHit } from '@objectstack/spec/ai';

// Validate data
const result = KnowledgeChunk.parse(data);

KnowledgeChunk

Properties

PropertyTypeRequiredDescription
idstring
documentIdstring
indexinteger
contentstring
metadataRecord<string, any>optional

KnowledgeDocument

Properties

PropertyTypeRequiredDescription
idstringDocument id
sourceIdstringOwning KnowledgeSource id
sourceRecordIdstringoptional
contentstring
titlestringoptional
metadataRecord<string, any>optional
permissionsstring[]optional

KnowledgeHit

Properties

PropertyTypeRequiredDescription
chunkIdstring
documentIdstring
sourceIdstring
sourceRecordIdstringoptional
scorenumber
snippetstring
titlestringoptional
metadataRecord<string, any>optional

On this page