import { type ClientOptions, OpenAI as OpenAIClient } from "openai"; import { CallbackManagerForLLMRun } from "../callbacks/manager.js"; import { BaseMessage, ChatGenerationChunk, ChatResult } from "../schema/index.js"; import { StructuredTool } from "../tools/base.js"; import { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput, OpenAICoreRequestOptions, LegacyOpenAIInput } from "../types/openai-types.js"; import { BaseChatModel, BaseChatModelParams } from "./base.js"; import { BaseFunctionCallOptions } from "../base_language/index.js"; export { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput }; interface TokenUsage { completionTokens?: number; promptTokens?: number; totalTokens?: number; } interface OpenAILLMOutput { tokenUsage: TokenUsage; } export interface ChatOpenAICallOptions extends OpenAICallOptions, BaseFunctionCallOptions { tools?: StructuredTool[]; promptIndex?: number; } /** * Wrapper around OpenAI large language models that use the Chat endpoint. * * To use you should have the `openai` package installed, with the * `OPENAI_API_KEY` environment variable set. * * To use with Azure you should have the `openai` package installed, with the * `AZURE_OPENAI_API_KEY`, * `AZURE_OPENAI_API_INSTANCE_NAME`, * `AZURE_OPENAI_API_DEPLOYMENT_NAME` * and `AZURE_OPENAI_API_VERSION` environment variable set. * `AZURE_OPENAI_BASE_PATH` is optional and will override `AZURE_OPENAI_API_INSTANCE_NAME` if you need to use a custom endpoint. * * @remarks * Any parameters that are valid to be passed to {@link * https://platform.openai.com/docs/api-reference/chat/create | * `openai.createChatCompletion`} can be passed through {@link modelKwargs}, even * if not explicitly available on this class. */ export declare class ChatOpenAI extends BaseChatModel implements OpenAIChatInput, AzureOpenAIInput { static lc_name(): string; get callKeys(): string[]; lc_serializable: boolean; get lc_secrets(): { [key: string]: string; } | undefined; get lc_aliases(): Record; temperature: number; topP: number; frequencyPenalty: number; presencePenalty: number; n: number; logitBias?: Record; modelName: string; modelKwargs?: OpenAIChatInput["modelKwargs"]; stop?: string[]; user?: string; timeout?: number; streaming: boolean; maxTokens?: number; openAIApiKey?: string; azureOpenAIApiVersion?: string; azureOpenAIApiKey?: string; azureOpenAIApiInstanceName?: string; azureOpenAIApiDeploymentName?: string; azureOpenAIBasePath?: string; organization?: string; private client; private clientConfig; constructor(fields?: Partial & Partial & BaseChatModelParams & { configuration?: ClientOptions & LegacyOpenAIInput; }, /** @deprecated */ configuration?: ClientOptions & LegacyOpenAIInput); /** * Get the parameters used to invoke the model */ invocationParams(options?: this["ParsedCallOptions"]): Omit; /** @ignore */ _identifyingParams(): Omit & { model_name: string; } & ClientOptions; _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator; /** * Get the identifying parameters for the model */ identifyingParams(): Omit & { model_name: string; } & ClientOptions; /** @ignore */ _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise; getNumTokensFromMessages(messages: BaseMessage[]): Promise<{ totalCount: number; countPerMessage: number[]; }>; /** * Calls the OpenAI API with retry logic in case of failures. * @param request The request to send to the OpenAI API. * @param options Optional configuration for the API call. * @returns The response from the OpenAI API. */ completionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsStreaming, options?: OpenAICoreRequestOptions): Promise>; completionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming, options?: OpenAICoreRequestOptions): Promise; private _getClientOptions; _llmType(): string; /** @ignore */ _combineLLMOutput(...llmOutputs: OpenAILLMOutput[]): OpenAILLMOutput; } export declare class PromptLayerChatOpenAI extends ChatOpenAI { promptLayerApiKey?: string; plTags?: string[]; returnPromptLayerId?: boolean; constructor(fields?: ConstructorParameters[0] & { promptLayerApiKey?: string; plTags?: string[]; returnPromptLayerId?: boolean; }); _generate(messages: BaseMessage[], options?: string[] | ChatOpenAICallOptions, runManager?: CallbackManagerForLLMRun): Promise; }