UNPKG

askexperts

Version:

AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol

53 lines (52 loc) 1.85 kB
import { DocStoreClient, Doc } from "../docstore/interfaces.js"; import { RagDB } from "./interfaces.js"; /** * Options for syncing documents from a docstore to a RagDB */ export interface SyncOptions { /** ID of the docstore to sync */ docstore_id: string; /** Name of the collection to store documents in */ collection_name: string; /** Optional type of documents to filter by */ type?: string; /** Optional callback to call when all documents have been synced */ onEof?: () => void; /** Optional callback to let client watch the docs and filter them */ onDoc?: (doc: Doc) => Promise<boolean>; /** Optional callback to customize metadata for each document */ onDocMeta?: (doc: Doc, embedding: number[]) => Promise<any>; } /** * Class to sync documents from a DocStore to a RagDB */ export declare class DocstoreToRag { private ragDB; private docStoreClient; private activeSubscriptions; /** * Creates a new DocstoreToRag instance * @param ragDB - The RagDB instance to store embeddings in * @param docStoreClient - The DocStoreClient to get documents from */ constructor(ragDB: RagDB, docStoreClient: DocStoreClient); /** * Converts a Doc to an array of RagDocuments (one per embedding) * @param doc - The document to convert * @param onDocMeta - Optional callback to customize metadata * @returns Array of RagDocuments with vectors and metadata */ private docToRagDocuments; /** * Syncs documents from a docstore to the RagDB * @param options - Options for syncing * @returns Subscription with a stop method */ sync(options: SyncOptions): Promise<{ stop: () => void; }>; /** * Closes all active subscriptions when the object is disposed */ [Symbol.dispose](): void; }