import { AIMessageChunk, BaseMessage, MessageStructure } from "@langchain/core/messages"; import { RunnableBatchOptions, RunnableBinding, RunnableConfig, RunnableToolLike } from "@langchain/core/runnables"; import { StructuredToolInterface } from "@langchain/core/tools"; import { BaseLanguageModelInput, ToolDefinition } from "@langchain/core/language_models/base"; import { ChatResult } from "@langchain/core/outputs"; import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager"; import { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams, BindToolsInput } from "@langchain/core/language_models/chat_models"; import { IterableReadableStream } from "@langchain/core/utils/stream"; import { LogStreamCallbackHandlerInput, RunLogPatch, StreamEvent } from "@langchain/core/tracers/log_stream"; //#region src/chat_models/universal.d.ts interface EventStreamCallbackHandlerInput extends Omit {} interface ConfigurableChatModelCallOptions extends BaseChatModelCallOptions { tools?: (StructuredToolInterface | Record | ToolDefinition | RunnableToolLike)[]; } declare const MODEL_PROVIDER_CONFIG: { readonly openai: { readonly package: "@langchain/openai"; readonly className: "ChatOpenAI"; }; readonly anthropic: { readonly package: "@langchain/anthropic"; readonly className: "ChatAnthropic"; }; readonly azure_openai: { readonly package: "@langchain/openai"; readonly className: "AzureChatOpenAI"; }; readonly cohere: { readonly package: "@langchain/cohere"; readonly className: "ChatCohere"; }; readonly "google-vertexai": { readonly package: "@langchain/google-vertexai"; readonly className: "ChatVertexAI"; }; readonly "google-vertexai-web": { readonly package: "@langchain/google-vertexai-web"; readonly className: "ChatVertexAI"; }; readonly "google-genai": { readonly package: "@langchain/google-genai"; readonly className: "ChatGoogleGenerativeAI"; }; readonly ollama: { readonly package: "@langchain/ollama"; readonly className: "ChatOllama"; }; readonly mistralai: { readonly package: "@langchain/mistralai"; readonly className: "ChatMistralAI"; }; readonly groq: { readonly package: "@langchain/groq"; readonly className: "ChatGroq"; }; readonly cerebras: { readonly package: "@langchain/cerebras"; readonly className: "ChatCerebras"; }; readonly bedrock: { readonly package: "@langchain/aws"; readonly className: "ChatBedrockConverse"; }; readonly aws: { readonly package: "@langchain/aws"; readonly className: "ChatBedrockConverse"; }; readonly deepseek: { readonly package: "@langchain/deepseek"; readonly className: "ChatDeepSeek"; }; readonly xai: { readonly package: "@langchain/xai"; readonly className: "ChatXAI"; }; readonly fireworks: { readonly package: "@langchain/fireworks"; readonly className: "ChatFireworks"; }; readonly together: { readonly package: "@langchain/together-ai"; readonly className: "ChatTogetherAI"; readonly hasCircularDependency: true; }; readonly perplexity: { readonly package: "@langchain/perplexity"; readonly className: "ChatPerplexity"; }; }; type ChatModelProvider = keyof typeof MODEL_PROVIDER_CONFIG; /** * Helper function to get a chat model class by its class name or model provider. * @param className The class name (e.g., "ChatOpenAI", "ChatAnthropic") * @param modelProvider Optional model provider key for direct lookup (e.g., "google-vertexai-web"). * When provided, uses direct lookup to avoid className collision issues. * @returns The imported model class or undefined if not found */ declare function getChatModelByClassName(className: string, modelProvider?: string): Promise; /** * Attempts to infer the model provider based on the given model name. * * @param {string} modelName - The name of the model to infer the provider for. * @returns {string | undefined} The inferred model provider name, or undefined if unable to infer. * * @example * _inferModelProvider("gpt-4"); // returns "openai" * _inferModelProvider("claude-2"); // returns "anthropic" * _inferModelProvider("unknown-model"); // returns undefined */ declare function _inferModelProvider(modelName: string): string | undefined; interface ConfigurableModelFields extends BaseChatModelParams { defaultConfig?: Record; /** * @default "any" */ configurableFields?: string[] | "any"; /** * @default "" */ configPrefix?: string; /** * Methods which should be called after the model is initialized. * The key will be the method name, and the value will be the arguments. */ queuedMethodOperations?: Record; } /** * Internal class used to create chat models. * * @internal */ declare class ConfigurableModel extends BaseChatModel { _llmType(): string; lc_namespace: string[]; _defaultConfig?: Record; /** * @default "any" */ _configurableFields: string[] | "any"; /** * @default "" */ _configPrefix: string; /** * Methods which should be called after the model is initialized. * The key will be the method name, and the value will be the arguments. */ _queuedMethodOperations: Record; constructor(fields: ConfigurableModelFields); _model(config?: RunnableConfig): Promise>>; _generate(messages: BaseMessage[], options?: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise; bindTools(tools: BindToolsInput[], params?: Record): ConfigurableModel; withStructuredOutput: BaseChatModel["withStructuredOutput"]; _modelParams(config?: RunnableConfig): Record; _removePrefix(str: string, prefix: string): string; /** * Bind config to a Runnable, returning a new Runnable. * @param {RunnableConfig | undefined} [config] - The config to bind. * @returns {RunnableBinding} A new RunnableBinding with the bound config. */ withConfig(config?: RunnableConfig): RunnableBinding; invoke(input: RunInput, options?: CallOptions): Promise; stream(input: RunInput, options?: CallOptions): Promise>; batch(inputs: RunInput[], options?: Partial | Partial[], batchOptions?: RunnableBatchOptions & { returnExceptions?: false; }): Promise; batch(inputs: RunInput[], options?: Partial | Partial[], batchOptions?: RunnableBatchOptions & { returnExceptions: true; }): Promise<(AIMessageChunk | Error)[]>; batch(inputs: RunInput[], options?: Partial | Partial[], batchOptions?: RunnableBatchOptions): Promise<(AIMessageChunk | Error)[]>; transform(generator: AsyncGenerator, options: CallOptions): AsyncGenerator; streamLog(input: RunInput, options?: Partial, streamOptions?: Omit): AsyncGenerator; streamEvents(input: RunInput, options: Partial & { version: "v1" | "v2"; }, streamOptions?: Omit): IterableReadableStream; streamEvents(input: RunInput, options: Partial & { version: "v1" | "v2"; encoding: "text/event-stream"; }, streamOptions?: Omit): IterableReadableStream; } interface InitChatModelFields extends Partial> { modelProvider?: string; configurableFields?: string[] | "any"; configPrefix?: string; } type ConfigurableFields = "any" | string[]; declare function initChatModel(model: string, fields?: Partial> & { modelProvider?: string; configurableFields?: never; configPrefix?: string; }): Promise>; declare function initChatModel(model: never, options?: Partial> & { modelProvider?: string; configurableFields?: never; configPrefix?: string; }): Promise>; declare function initChatModel(model?: string, options?: Partial> & { modelProvider?: string; configurableFields?: ConfigurableFields; configPrefix?: string; }): Promise>; //#endregion export { ChatModelProvider, ConfigurableChatModelCallOptions, ConfigurableFields, ConfigurableModel, InitChatModelFields, MODEL_PROVIDER_CONFIG, _inferModelProvider, getChatModelByClassName, initChatModel }; //# sourceMappingURL=universal.d.ts.map