import OpenAI from "openai"; import { APIPromise } from "openai/core"; import { ChatCompletionMessageParam } from "openai/resources/chat"; import { Stream } from "openai/streaming"; import { DeepPartial } from "ts-essentials"; import { ResponseMetrics } from "./session"; import { ObjectTemplate } from "./template"; export type ResolvedToolCall = DeepPartial; interface ResolvedAPIResult { response: string | null | undefined; /** Calls to any tools */ tool_calls?: ResolvedToolCall[]; responseMetrics?: ResponseMetrics; streamRawResponse?: any; } export type ResolvedReturnValue = Stream | Stream | OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion; /** This function papers over the difference between streamed and unstreamed * responses. It splits the response into two parts: * 1. The return value, which is what the caller should return immediately (may * be stream or raw result) * 2. A promise that resolves to the final (string) result. If the original * response is streamed, this promise doesn't resolve until the stream is * finished. */ export declare function getResolvedStream(resultPromise: APIPromise | Stream | OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion>, stream: boolean | null | undefined, feedbackKey: string, isChat: boolean): Promise<{ returnValue: ResolvedReturnValue; finalResultPromise: Promise; }>; type PromptString = string | string[] | number[] | number[][] | null; export declare function getResolvedMessages(messages: ChatCompletionMessageParam[] | ObjectTemplate, params?: Record): { messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[]; template: OpenAI.Chat.Completions.ChatCompletionMessageParam[]; } | { messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[]; template: null; }; export declare function getResolvedPrompt(s: PromptString | ObjectTemplate, params?: Record): { prompt: string; template: null; } | { prompt: null; template: null; } | { prompt: string; template: string; }; export {};