import { UserInfo, IMetadataProvider } from '@memberjunction/core'; /** * Result from an embedding execution via AIModelRunner. */ export interface EmbeddingRunResult { /** Whether the embedding call succeeded */ Success: boolean; /** The embedding vectors (one per input text) */ Vectors: number[][]; /** The AIPromptRun ID created for tracking */ PromptRunID: string | null; /** Total tokens used */ TokensUsed: number; /** Cost of the call */ Cost: number; /** Error message if failed */ ErrorMessage: string | null; /** Execution time in milliseconds */ ExecutionTimeMs: number; } /** * Parameters for running an embedding via AIModelRunner. */ export interface EmbeddingRunParams { /** The texts to embed */ Texts: string[]; /** Optional: specific AIPrompt ID for this embedding operation (type=Embedding). * If not provided, uses the first active Embedding prompt found. */ PromptID?: string; /** Optional: specific model ID to use. If not provided, uses the prompt's model configuration. */ ModelID?: string; /** The user context for permissions and audit */ ContextUser: UserInfo; /** Optional: parent run ID (e.g., agent run, classification run) for hierarchical tracking */ ParentRunID?: string; /** Optional: human-readable description for the AIPromptRun record */ Description?: string; } /** * AIModelRunner — Lightweight AI model execution tracker for non-LLM model types. * * Creates AIPromptRun records for embedding calls (and future: image, audio, video) * with full token/cost tracking. Uses the same model selection and vendor failover * infrastructure as AIPromptRunner but without template rendering or validation. * * Architecture: * - @memberjunction/ai (no MJ infra): BaseEmbeddings, ModelUsage * - @memberjunction/ai-core-plus (this class): AIModelRunner — creates AIPromptRun records * - @memberjunction/ai-prompts: AIPromptRunner — LLM-specific (template rendering, validation) * * Usage: * ```typescript * const runner = new AIModelRunner(); * const result = await runner.RunEmbedding({ * Texts: ['Hello world', 'How are you'], * ContextUser: currentUser, * Description: 'Content item vectorization' * }); * // result.PromptRunID links to the AIPromptRun record with token/cost data * ``` */ export declare class AIModelRunner { private _provider; /** * Fire-and-forget AIPromptRun persistence via the shared {@link BaseEntitySaveQueue}. The * embedding/model run record is observability — the caller gets its vectors regardless of whether * the tracking row persists — so saves are queued, not awaited, and the embedding call is never * blocked on a DB round-trip. The queue sequences saves per entity (the initial 'Running' INSERT * always completes before the 'Completed'/'Failed' UPDATE). `PromptRunID` is returned immediately * because `NewRecord()` client-generates the UUID. */ private _promptRunQueue; /** * Optional metadata provider override. Callers should set * `instance.Provider = providerToUse` before invoking run methods * in multi-provider contexts. Falls back to the global default provider when unset. */ get Provider(): IMetadataProvider; set Provider(value: IMetadataProvider | null); /** * Execute an embedding call with full AIPromptRun tracking. * * Creates an AIPromptRun record before the call, invokes the embedding model, * stores tokens/cost/timing on the run record, and returns the result. * * @param params - Embedding execution parameters * @returns Result with vectors, run ID, and usage metrics */ RunEmbedding(params: EmbeddingRunParams): Promise; private resolveEmbeddingModel; private findBestVendor; private createRunRecord; /** * Awaits all in-flight prompt-run saves queued by this runner. The normal path does NOT * call this — persistence is intentionally fire-and-forget. For tests / durability needs. */ WaitForPendingPromptRunSaves(): Promise; private completeRunRecord; private failRunRecord; private errorResult; } //# sourceMappingURL=AIModelRunner.d.ts.map