mongodb-rag-core
Version:
Common elements used by MongoDB Chatbot Framework components.
36 lines • 1.34 kB
TypeScript
import { ContentChunk } from "./chunkPage";
import { Page } from "../contentStore/Page";
export type ChunkTransformer = (chunk: Omit<ContentChunk, "tokenCount">, details: {
page: Page;
}) => Promise<Omit<ContentChunk, "tokenCount">>;
export type ChunkMetadataGetter<T extends Record<string, unknown> = Record<string, unknown>> = (args: {
chunk: Omit<ContentChunk, "tokenCount">;
page: Page;
/**
Previous metadata, if any. Omitting this from the return value should not
overwrite previous metadata.
*/
metadata?: T;
/**
The text of the chunk without metadata.
*/
text: string;
}) => Promise<T>;
/**
Create a function that adds or updates front matter metadata to the chunk
text.
*/
export declare const makeChunkFrontMatterUpdater: <T extends Record<string, unknown> = Record<string, unknown>>(getMetadata: ChunkMetadataGetter<T>) => ChunkTransformer;
/**
Forms common metadata based on the chunk text, including info about any code
examples in the text.
*/
export declare const standardMetadataGetter: ChunkMetadataGetter<{
pageTitle?: string;
hasCodeBlock: boolean;
codeBlockLanguages?: string[];
tags?: string[];
[k: string]: unknown;
}>;
export declare const standardChunkFrontMatterUpdater: ChunkTransformer;
//# sourceMappingURL=ChunkTransformer.d.ts.map