import { type References } from "../references"; import { type Promotion } from "../promotions"; import { type AddMessageRequestBody, type AssistantMessageMetadata, type ChatService, type ConversationData, type ConversationFetchOptions, type MessageData } from "./conversations"; /** * Tool definition for the Responses API. */ export type ResponsesTool = { type: "function"; strict: boolean; name: string; description?: string; parameters: JsonObject; }; /** * Tool choice for the Responses API. */ export type ResponsesToolChoice = "auto" | { type: "function"; name: string; }; export type ResponsesServiceConfig = { serverUrl: string; model: string; store: boolean; fetchOptions?: ConversationFetchOptions | (() => ConversationFetchOptions); user?: string; instructions?: string; tools?: ResponsesTool[]; toolChoice?: ResponsesToolChoice; metadata?: Record; /** * API key for authentication. Required by the AI SDK. * For MongoDB Assistant, this is typically set via fetchOptions headers. */ apiKey?: string; }; type JsonValue = null | string | number | boolean | JsonObject | JsonValue[]; type JsonObject = { [key: string]: JsonValue | undefined; }; export declare class ResponsesService implements ChatService { private serverUrl; private config; constructor(config: ResponsesServiceConfig); /** * Get fetch options, evaluating the function if dynamic. */ private getFetchOptions; private getModel; private toStatelessPrompt; createConversation(): Promise; getConversation(_conversationId: string): Promise; addMessage({ conversationId, conversation, message, historyMessages, clientContext: _clientContext, previousResponseId, }: { conversationId: string; } & AddMessageRequestBody): Promise; addMessageStreaming({ conversationId: _conversationId, conversation, message, historyMessages, previousResponseId, maxRetries, onResponseDelta, onReferences, onPromotion, onMetadata, onResponseFinished, signal, }: { conversationId: string; maxRetries?: number; onResponseDelta: (delta: string) => void; onReferences: (references: References) => void; onPromotion: (promotion: Promotion) => void; onMetadata: (metadata: AssistantMessageMetadata) => void; onResponseFinished: (messageId: string) => void; signal?: AbortSignal; } & AddMessageRequestBody): Promise; /** * Rate a message using the Responses API standalone message endpoint. * Unlike the Conversations API, this doesn't require a conversationId. * @see https://knowledge.mongodb.com/api/v1/conversations/messages/{messageId}/rating */ rateMessage({ messageId, rating, }: { conversationId: string; messageId: string; rating: boolean; }): Promise; /** * Comment on a message using the Responses API standalone message endpoint. * Unlike the Conversations API, this doesn't require a conversationId. * @see https://knowledge.mongodb.com/api/v1/conversations/messages/{messageId}/comment */ commentMessage({ messageId, comment, }: { conversationId: string; messageId: string; comment: string; }): Promise; } export {};