UNPKG

@promptbook/remote-server

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

93 lines (92 loc) 3.32 kB
import type { ClientOptions } from 'openai'; import type OpenAI from 'openai'; import type { string_title } from '../../types/string_title'; import type { TODO_any } from '../../utils/organization/TODO_any'; import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions'; import { OpenAiExecutionTools } from './OpenAiExecutionTools'; /** * Shared options for OpenAI vector store handling. * * @public exported from `@promptbook/openai` */ export type OpenAiVectorStoreHandlerOptions = OpenAiCompatibleExecutionToolsOptions & ClientOptions & { /** * Per-knowledge-source download timeout in milliseconds when preparing vector stores. * * @default 30000 */ readonly knowledgeSourceDownloadTimeoutMs?: number; /** * Max concurrency for uploading knowledge source files to the vector store. * * @default 5 */ readonly knowledgeSourceUploadMaxConcurrency?: number; /** * Poll interval in milliseconds when waiting for vector store file batch processing. * * @default 5000 */ readonly knowledgeSourceUploadPollIntervalMs?: number; /** * Overall timeout in milliseconds for vector store file batch processing. * * @default 900000 */ readonly knowledgeSourceUploadTimeoutMs?: number; /** * Whether we should continue even if vector store ingestion stalls. * * @default true */ readonly shouldContinueOnVectorStoreStall?: boolean; }; /** * Base class for OpenAI execution tools that need hosted vector stores. * * @public exported from `@promptbook/openai` */ export declare abstract class OpenAiVectorStoreHandler extends OpenAiExecutionTools { /** * Returns the per-knowledge-source download timeout in milliseconds. */ protected getKnowledgeSourceDownloadTimeoutMs(): number; /** * Returns the max concurrency for knowledge source uploads. */ protected getKnowledgeSourceUploadMaxConcurrency(): number; /** * Returns the polling interval in milliseconds for vector store uploads. */ protected getKnowledgeSourceUploadPollIntervalMs(): number; /** * Returns the overall upload timeout in milliseconds for vector store uploads. */ protected getKnowledgeSourceUploadTimeoutMs(): number; /** * Returns true if we should continue even if vector store ingestion stalls. */ protected shouldContinueOnVectorStoreStall(): boolean; /** * Returns vector-store-specific options with extended settings. */ protected get vectorStoreOptions(): OpenAiVectorStoreHandlerOptions; /** * Returns the OpenAI vector stores API surface, supporting stable and beta SDKs. */ protected getVectorStoresApi(client: OpenAI): TODO_any; /** * Creates a vector store and uploads knowledge sources, returning its ID. */ protected createVectorStoreWithKnowledgeSources(options: { readonly client: OpenAI; readonly name: string_title; readonly knowledgeSources: ReadonlyArray<string>; readonly logLabel: string; }): Promise<{ readonly vectorStoreId: string; readonly uploadedFileCount: number; readonly skippedCount: number; readonly totalBytes: number; }>; }