UNPKG

ravendb

Version:
56 lines 3.17 kB
import type { AiAgentActionRequest } from "./Agents/AiAgentActionRequest.js"; import type { AiConversationCreationOptions } from "./Agents/AiConversationCreationOptions.js"; import type { AiAnswer } from "./AiAnswer.js"; import type { AiStreamCallback } from "./AiStreamCallback.js"; import type { IDocumentStore } from "../../IDocumentStore.js"; import type { UnhandledActionEventArgs } from "./UnhandledActionEventArgs.js"; export declare enum AiHandleErrorStrategy { SendErrorsToModel = "SendErrorsToModel", RaiseImmediately = "RaiseImmediately" } export type ActionInvocation = (request: AiAgentActionRequest) => Promise<void>; export declare class AiConversation { private readonly _store; private readonly _databaseName; private readonly _agentId; private _conversationId; private readonly _options?; private _actionRequests; private readonly _actionResponses; private _userPrompt?; private readonly _invocations; onUnhandledAction?: (args: UnhandledActionEventArgs) => Promise<void> | void; constructor(store: IDocumentStore, databaseName: string, agentId: string, conversationId: string, options?: AiConversationCreationOptions, changeVector?: string); private _changeVector; get changeVector(): string; get id(): string; requiredActions(): AiAgentActionRequest[]; addActionResponse<TResponse>(toolId: string, actionResponse: TResponse | string): void; setUserPrompt(userPrompt: string): void; handle<TArgs = any>(actionName: string, action: (args: TArgs) => Promise<object>, aiHandleError?: AiHandleErrorStrategy): void; handle<TArgs = any>(actionName: string, action: (args: TArgs) => object, aiHandleError?: AiHandleErrorStrategy): void; handle<TArgs = any>(actionName: string, action: (request: AiAgentActionRequest, args: TArgs) => Promise<object>, aiHandleError?: AiHandleErrorStrategy): void; handle<TArgs = any>(actionName: string, action: (request: AiAgentActionRequest, args: TArgs) => object, aiHandleError?: AiHandleErrorStrategy): void; receive<TArgs = any>(actionName: string, action: (request: AiAgentActionRequest, args: TArgs) => Promise<void> | void, aiHandleError?: AiHandleErrorStrategy): void; run<TAnswer>(): Promise<AiAnswer<TAnswer>>; /** * Executes one "turn" of the conversation with streaming enabled. * Streams the specified property's value in real-time by invoking the callback with each chunk. * * @param streamPropertyPath - The property path of the answer to stream (e.g., "suggestedReward") * @param streamCallback - Callback invoked with each streamed chunk * @returns A promise that resolves to the full answer after streaming completes * * @example * ```typescript * const answer = await chat.stream<TAnswer>("propertyName", async (chunk) => { * console.log("Received chunk:", chunk); * }); * ``` */ stream<TAnswer>(streamPropertyPath: string, streamCallback: AiStreamCallback): Promise<AiAnswer<TAnswer>>; private _runInternal; private _parseArgs; private _createErrorMessageForLlm; } //# sourceMappingURL=AiConversation.d.ts.map