@langchain/anthropic 1.0.0-alpha.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.d.cts","names":["Anthropic","ClientOptions","Stream","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","ChatAnthropicToolType","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","Kwargs","ChatAnthropicMessages","CallOptions","Messages","ToolUnion","Partial","Omit","Metadata","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","RunOutput","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicToolType } from \"./types.js\";\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /** Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temp closer to 0 for analytical /\n * multiple choice, and temp closer to 1 for creative\n * and generative tasks.\n * To not set this field, pass `null`. If `undefined` is passed,\n * the default (1) will be used.\n */\n temperature?: number | null;\n /** Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses. Defaults to -1, which disables it.\n */\n topK?: number;\n /** Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Defaults to -1, which disables it.\n * Note that you should either alter temperature or top_p,\n * but not both.\n *\n * To not set this field, pass `null`. If `undefined` is passed,\n * the default (-1) will be used.\n *\n * For Opus 4.1 and Sonnet 4.5, this defaults to `null`.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /** A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n}\n/**\n * A type representing additional parameters that can be passed to the\n * Anthropic API.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Kwargs = Record<string, any>;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-3-5-sonnet-20240620\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-3-5-sonnet-20240620\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-3-5-sonnet-20240620\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-3-5-sonnet-20240620\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-3-5-sonnet-20240620',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature: number | undefined;\n topK: number;\n topP: number | undefined;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n // Used for non-streaming requests\n protected batchClient: Anthropic;\n // Used for streaming requests\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: AnthropicInput & BaseChatModelParams);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): Omit<AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams, \"messages\"> & Kwargs;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\nexport {};\n"],"mappings":";;;;;;;;;;;;;UAUiBwB,wBAAAA,SAAiCf,0BAA0BkB,KAAKF;UACrEF;;AADZ;;;EAA+F,WACnFA,CAAAA,EAKMD,mBALNC;EAAqB;;;;EAD+C,OAAA,CAAA,EAWlEG,MAXkE,CAAA,MAAA,EAAA,MAAA,CAAA;EAqBpEE;;;;EAAkE,SAAA,CAAA,EAAA,MAAA;AAI9E;;;;AAgDoB3B,KApDR2B,wBAAAA,GAA2B5B,WAAAA,CAAU6B,KAoD7B5B,GAAAA,CAAAA,MAAAA,GApD+C6B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U+C;;aAEhB/C,WAAAA,CAAUgD;;;;sBAIL3C,gEAAgEF,2BAA2B8C,QAAQ1C;;;;;;;2CAO9Ea,wCAAwCW,kBAAkBZ,0BAA0B8B,QAAQ/C,OAAOgB;;yCAErGD,+BAA+Bc,iBAAiBZ,0BAA0B8B,QAAQjD,WAAAA,CAAUkD;;;;oBAIjHxB,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bd,uCAAuCE,SAASD,wBAAwBsC;;;oBAGvFzB,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bd,sCAAsCE,SAASD;SACvER;YACG8C;;;cAGKC,aAAAA,SAAsBpB,qBAAqB"}
1
+ {"version":3,"file":"chat_models.d.cts","names":["Anthropic","ClientOptions","Stream","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","ModelProfile","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","ChatAnthropicToolType","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","Kwargs","ChatAnthropicMessages","CallOptions","Messages","ToolUnion","Partial","Omit","Metadata","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","RunOutput","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicToolType } from \"./types.js\";\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temperature closer to 0 for analytical /\n * multiple choice, and temperature closer to 1 for creative\n * and generative tasks.\n */\n temperature?: number;\n /**\n * Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses.\n */\n topK?: number;\n /**\n * Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Note that you should either alter\n * temperature or top_p, but not both.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /**\n * A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n}\n/**\n * A type representing additional parameters that can be passed to the\n * Anthropic API.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Kwargs = Record<string, any>;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-sonnet-4-5-20250929',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature?: number;\n topK?: number;\n topP?: number;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n // Used for non-streaming requests\n protected batchClient: Anthropic;\n // Used for streaming requests\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: AnthropicInput & BaseChatModelParams);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): Omit<AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams, \"messages\"> & Kwargs;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({ model: \"claude-opus-4-0\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 200000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable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AAAA,CAAUoC;;;;;;;;;;;WAWXpC,WAAAA,CAAU8B;eACN9B,WAAAA,CAAUuC;;;sBAGHvC,WAAAA,CAAUwC;;eAEjBxC,WAAAA,CAAUyC;kBACPzC,WAAAA,CAAU0C;YAChB1C,WAAAA,CAAUoC;;;;;;kCAMU/B,gEAAgEF,2BAA2BwC,eAAerC;;kCAE1GD,uBAAuBiC,KAAKtC,WAAAA,CAAUmC,QAAAA,CAASS,kCAAkC5C,WAAAA,CAAUmC,QAAAA,CAASU,4CAA4Cb,wBAAwBZ,0BAA0B8B;iBAAHJ,wBAAAA,CAC5KC,cAAAA;;;aAGpC/C,WAAAA,CAAU8B;mBACJ9B,WAAAA,CAAUgD;;aAEhBhD,WAAAA,CAAUiD;;;;sBAIL5C,gEAAgEF,2BAA2B+C,QAAQ3C;;;;;;;2CAO9Ec,wCAAwCW,kBAAkBZ,0BAA0B8B,QAAQhD,OAAOiB;;yCAErGD,+BAA+Bc,iBAAiBZ,0BAA0B8B,QAAQlD,WAAAA,CAAUmD;;;;;;;;;;;;;;;;;;;iBAmBpHrC;;;oBAGGa,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bf,uCAAuCG,SAASF,wBAAwBuC;;;oBAGvFzB,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bf,sCAAsCG,SAASF;SACvER;YACG+C;;;cAGKC,aAAAA,SAAsBpB,qBAAqB"}
@@ -9,6 +9,7 @@ import { Runnable } from "@langchain/core/runnables";
9
9
  import { InteropZodType } from "@langchain/core/utils/types";
10
10
  import { Stream } from "@anthropic-ai/sdk/streaming";
11
11
  import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
12
+ import { ModelProfile } from "@langchain/core/language_models/profile";
12
13
 
13
14
  //#region src/chat_models.d.ts
14
15
  interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, "streamUsage"> {
@@ -37,36 +38,32 @@ type AnthropicMessagesModelId = Anthropic$1.Model | (string & NonNullable<unknow
37
38
  * Input to AnthropicChat class.
38
39
  */
39
40
  interface AnthropicInput {
40
- /** Amount of randomness injected into the response. Ranges
41
- * from 0 to 1. Use temp closer to 0 for analytical /
42
- * multiple choice, and temp closer to 1 for creative
41
+ /**
42
+ * Amount of randomness injected into the response. Ranges
43
+ * from 0 to 1. Use temperature closer to 0 for analytical /
44
+ * multiple choice, and temperature closer to 1 for creative
43
45
  * and generative tasks.
44
- * To not set this field, pass `null`. If `undefined` is passed,
45
- * the default (1) will be used.
46
46
  */
47
- temperature?: number | null;
48
- /** Only sample from the top K options for each subsequent
47
+ temperature?: number;
48
+ /**
49
+ * Only sample from the top K options for each subsequent
49
50
  * token. Used to remove "long tail" low probability
50
- * responses. Defaults to -1, which disables it.
51
+ * responses.
51
52
  */
52
53
  topK?: number;
53
- /** Does nucleus sampling, in which we compute the
54
+ /**
55
+ * Does nucleus sampling, in which we compute the
54
56
  * cumulative distribution over all the options for each
55
57
  * subsequent token in decreasing probability order and
56
58
  * cut it off once it reaches a particular probability
57
- * specified by top_p. Defaults to -1, which disables it.
58
- * Note that you should either alter temperature or top_p,
59
- * but not both.
60
- *
61
- * To not set this field, pass `null`. If `undefined` is passed,
62
- * the default (-1) will be used.
63
- *
64
- * For Opus 4.1 and Sonnet 4.5, this defaults to `null`.
59
+ * specified by top_p. Note that you should either alter
60
+ * temperature or top_p, but not both.
65
61
  */
66
62
  topP?: number | null;
67
63
  /** A maximum number of tokens to generate before stopping. */
68
64
  maxTokens?: number;
69
- /** A list of strings upon which to stop generating.
65
+ /**
66
+ * A list of strings upon which to stop generating.
70
67
  * You probably want `["\n\nHuman:"]`, as that's the cue for
71
68
  * the next turn in the dialog agent.
72
69
  */
@@ -159,7 +156,7 @@ type Kwargs = Record<string, any>;
159
156
  * import { ChatAnthropic } from '@langchain/anthropic';
160
157
  *
161
158
  * const llm = new ChatAnthropic({
162
- * model: "claude-3-5-sonnet-20240620",
159
+ * model: "claude-sonnet-4-5-20250929",
163
160
  * temperature: 0,
164
161
  * maxTokens: undefined,
165
162
  * maxRetries: 2,
@@ -189,7 +186,7 @@ type Kwargs = Record<string, any>;
189
186
  * "content": "Here's the translation to French:\n\nJ'adore la programmation.",
190
187
  * "response_metadata": {
191
188
  * "id": "msg_01QDpd78JUHpRP6bRRNyzbW3",
192
- * "model": "claude-3-5-sonnet-20240620",
189
+ * "model": "claude-sonnet-4-5-20250929",
193
190
  * "stop_reason": "end_turn",
194
191
  * "stop_sequence": null,
195
192
  * "usage": {
@@ -227,7 +224,7 @@ type Kwargs = Record<string, any>;
227
224
  * "id": "msg_01N8MwoYxiKo9w4chE4gXUs4",
228
225
  * "type": "message",
229
226
  * "role": "assistant",
230
- * "model": "claude-3-5-sonnet-20240620"
227
+ * "model": "claude-sonnet-4-5-20250929"
231
228
  * },
232
229
  * "usage_metadata": {
233
230
  * "input_tokens": 25,
@@ -296,7 +293,7 @@ type Kwargs = Record<string, any>;
296
293
  * "id": "msg_01SBTb5zSGXfjUc7yQ8EKEEA",
297
294
  * "type": "message",
298
295
  * "role": "assistant",
299
- * "model": "claude-3-5-sonnet-20240620",
296
+ * "model": "claude-sonnet-4-5-20250929",
300
297
  * "stop_reason": "end_turn",
301
298
  * "stop_sequence": null
302
299
  * },
@@ -481,7 +478,7 @@ type Kwargs = Record<string, any>;
481
478
  * ```txt
482
479
  * {
483
480
  * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',
484
- * model: 'claude-3-5-sonnet-20240620',
481
+ * model: 'claude-sonnet-4-5-20250929',
485
482
  * stop_reason: 'end_turn',
486
483
  * stop_sequence: null,
487
484
  * usage: { input_tokens: 25, output_tokens: 19 },
@@ -503,9 +500,9 @@ declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions
503
500
  anthropicApiKey?: string;
504
501
  apiKey?: string;
505
502
  apiUrl?: string;
506
- temperature: number | undefined;
507
- topK: number;
508
- topP: number | undefined;
503
+ temperature?: number;
504
+ topK?: number;
505
+ topP?: number;
509
506
  maxTokens: number;
510
507
  modelName: string;
511
508
  model: string;
@@ -600,6 +597,24 @@ declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions
600
597
  /** @ignore */
601
598
  protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic$1.Message>;
602
599
  _llmType(): string;
600
+ /**
601
+ * Return profiling information for the model.
602
+ *
603
+ * Provides information about the model's capabilities and constraints,
604
+ * including token limits, multimodal support, and advanced features like
605
+ * tool calling and structured output.
606
+ *
607
+ * @returns {ModelProfile} An object describing the model's capabilities and constraints
608
+ *
609
+ * @example
610
+ * ```typescript
611
+ * const model = new ChatAnthropic({ model: "claude-opus-4-0" });
612
+ * const profile = model.profile;
613
+ * console.log(profile.maxInputTokens); // 200000
614
+ * console.log(profile.imageInputs); // true
615
+ * ```
616
+ */
617
+ get profile(): ModelProfile;
603
618
  withStructuredOutput<
604
619
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
605
620
  RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.d.ts","names":["Anthropic","ClientOptions","Stream","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","ChatAnthropicToolType","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","Kwargs","ChatAnthropicMessages","CallOptions","Messages","ToolUnion","Partial","Omit","Metadata","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","RunOutput","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicToolType } from \"./types.js\";\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /** Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temp closer to 0 for analytical /\n * multiple choice, and temp closer to 1 for creative\n * and generative tasks.\n * To not set this field, pass `null`. If `undefined` is passed,\n * the default (1) will be used.\n */\n temperature?: number | null;\n /** Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses. Defaults to -1, which disables it.\n */\n topK?: number;\n /** Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Defaults to -1, which disables it.\n * Note that you should either alter temperature or top_p,\n * but not both.\n *\n * To not set this field, pass `null`. If `undefined` is passed,\n * the default (-1) will be used.\n *\n * For Opus 4.1 and Sonnet 4.5, this defaults to `null`.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /** A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n}\n/**\n * A type representing additional parameters that can be passed to the\n * Anthropic API.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Kwargs = Record<string, any>;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-3-5-sonnet-20240620\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-3-5-sonnet-20240620\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-3-5-sonnet-20240620\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-3-5-sonnet-20240620\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-3-5-sonnet-20240620',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature: number | undefined;\n topK: number;\n topP: number | undefined;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n // Used for non-streaming requests\n protected batchClient: Anthropic;\n // Used for streaming requests\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: AnthropicInput & BaseChatModelParams);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): Omit<AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams, \"messages\"> & Kwargs;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\nexport {};\n"],"mappings":";;;;;;;;;;;;;UAUiBwB,wBAAAA,SAAiCf,0BAA0BkB,KAAKF;UACrEF;;AADZ;;;EAA+F,WACnFA,CAAAA,EAKMD,mBALNC;EAAqB;;;;EAD+C,OAAA,CAAA,EAWlEG,MAXkE,CAAA,MAAA,EAAA,MAAA,CAAA;EAqBpEE;;;;EAAkE,SAAA,CAAA,EAAA,MAAA;AAI9E;;;;AAgDoB3B,KApDR2B,wBAAAA,GAA2B5B,WAAAA,CAAU6B,KAoD7B5B,GAAAA,CAAAA,MAAAA,GApD+C6B,WAoD/C7B,CAAAA,OAAAA,CAAAA,CAAAA;;;;AAyBIe,UAzEPS,cAAAA,CAyEOT;EAAqC;AAC5D;AA+XD;;;;;EAAqJ,WAAEZ,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;EAAc;;;;EAoB3H,IAClBY,CAAAA,EAAAA,MAAAA;EAAqC;;;;;;;;;;;;;EAqBgD,IAAEZ,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;EAAc;EAAa,SAA5DU,CAAAA,EAAAA,MAAAA;EAAQ;;;;EAIoE,aAI3Id,CAAAA,EAAU6B,MAAAA,EAAAA;EAAK;EACO,SAGX7B,CAAAA,EAAAA,OAAUuC;EAAc;EAEF,eAChBE,CAAAA,EAAAA,MAAAA;EAAU;EACP,MAWpBzC,CAAAA,EAAAA,MAAU6B;EAAK;EACO,eAGDU,CAAAA,EAAAA,MAAAA;EAAc;EAEF,SAC1BvC,CAAAA,EAzeN4B,wBAyegBa;EAAU;EACP,KAMCpC,CAAAA,EA9exBuB,wBA8ewBvB;EAAW;EAA6E,aAAkBC,CAAAA,EA5e1HL,aA4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CAAU6B;eACN7B,WAAAA,CAAUsC;;;sBAGHtC,WAAAA,CAAUuC;;eAEjBvC,WAAAA,CAAUwC;kBACPxC,WAAAA,CAAUyC;YAChBzC,WAAAA,CAAUmC;;;;;;;;;;;WAWXnC,WAAAA,CAAU6B;eACN7B,WAAAA,CAAUsC;;;sBAGHtC,WAAAA,CAAUuC;;eAEjBvC,WAAAA,CAAUwC;kBACPxC,WAAAA,CAAUyC;YAChBzC,WAAAA,CAAUmC;;;;;;kCAMU9B,gEAAgEF,2BAA2BuC,eAAepC;;kCAE1GD,uBAAuBgC,KAAKrC,WAAAA,CAAUkC,QAAAA,CAASS,kCAAkC3C,WAAAA,CAAUkC,QAAAA,CAASU,4CAA4Cb,wBAAwBZ,0BAA0B8B;iBAAHJ,wBAAAA,CAC5KC,cAAAA;;;aAGpC9C,WAAAA,CAAU6B;mBACJ7B,WAAAA,CAAU+C;;aAEhB/C,WAAAA,CAAUgD;;;;sBAIL3C,gEAAgEF,2BAA2B8C,QAAQ1C;;;;;;;2CAO9Ea,wCAAwCW,kBAAkBZ,0BAA0B8B,QAAQ/C,OAAOgB;;yCAErGD,+BAA+Bc,iBAAiBZ,0BAA0B8B,QAAQjD,WAAAA,CAAUkD;;;;oBAIjHxB,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bd,uCAAuCE,SAASD,wBAAwBsC;;;oBAGvFzB,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bd,sCAAsCE,SAASD;SACvER;YACG8C;;;cAGKC,aAAAA,SAAsBpB,qBAAqB"}
1
+ {"version":3,"file":"chat_models.d.ts","names":["Anthropic","ClientOptions","Stream","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","StructuredOutputMethodOptions","BaseLanguageModelInput","ModelProfile","Runnable","InteropZodType","AnthropicContextManagementConfigParam","AnthropicMessageCreateParams","AnthropicMessageStreamEvent","AnthropicRequestOptions","AnthropicStreamingMessageCreateParams","AnthropicThinkingConfigParam","AnthropicToolChoice","ChatAnthropicToolType","ChatAnthropicCallOptions","AnthropicInput","Record","Pick","AnthropicMessagesModelId","Model","NonNullable","Kwargs","ChatAnthropicMessages","CallOptions","Messages","ToolUnion","Partial","Omit","Metadata","TextBlockParam","ThinkingConfigParam","ToolChoice","AsyncGenerator","MessageCreateParamsNonStreaming","MessageCreateParamsStreaming","_langchain_core_outputs0","ChatGeneration","StopReason","Usage","Promise","Message","RunOutput","ChatAnthropic"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { Anthropic, type ClientOptions } from \"@anthropic-ai/sdk\";\nimport type { Stream } from \"@anthropic-ai/sdk/streaming\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, type BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, type ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, BaseChatModelCallOptions, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { type StructuredOutputMethodOptions, type BaseLanguageModelInput } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { AnthropicContextManagementConfigParam, AnthropicMessageCreateParams, AnthropicMessageStreamEvent, AnthropicRequestOptions, AnthropicStreamingMessageCreateParams, AnthropicThinkingConfigParam, AnthropicToolChoice, ChatAnthropicToolType } from \"./types.js\";\nexport interface ChatAnthropicCallOptions extends BaseChatModelCallOptions, Pick<AnthropicInput, \"streamUsage\"> {\n tools?: ChatAnthropicToolType[];\n /**\n * Whether or not to specify what tool the model should use\n * @default \"auto\"\n */\n tool_choice?: AnthropicToolChoice;\n /**\n * Custom headers to pass to the Anthropic API\n * when making a request.\n */\n headers?: Record<string, string>;\n /**\n * Container ID for file persistence across turns with code execution.\n * Used with the code_execution_20250825 tool.\n */\n container?: string;\n}\n/**\n * @see https://docs.anthropic.com/claude/docs/models-overview\n */\nexport type AnthropicMessagesModelId = Anthropic.Model | (string & NonNullable<unknown>);\n/**\n * Input to AnthropicChat class.\n */\nexport interface AnthropicInput {\n /**\n * Amount of randomness injected into the response. Ranges\n * from 0 to 1. Use temperature closer to 0 for analytical /\n * multiple choice, and temperature closer to 1 for creative\n * and generative tasks.\n */\n temperature?: number;\n /**\n * Only sample from the top K options for each subsequent\n * token. Used to remove \"long tail\" low probability\n * responses.\n */\n topK?: number;\n /**\n * Does nucleus sampling, in which we compute the\n * cumulative distribution over all the options for each\n * subsequent token in decreasing probability order and\n * cut it off once it reaches a particular probability\n * specified by top_p. Note that you should either alter\n * temperature or top_p, but not both.\n */\n topP?: number | null;\n /** A maximum number of tokens to generate before stopping. */\n maxTokens?: number;\n /**\n * A list of strings upon which to stop generating.\n * You probably want `[\"\\n\\nHuman:\"]`, as that's the cue for\n * the next turn in the dialog agent.\n */\n stopSequences?: string[];\n /** Whether to stream the results or not */\n streaming?: boolean;\n /** Anthropic API key */\n anthropicApiKey?: string;\n /** Anthropic API key */\n apiKey?: string;\n /** Anthropic API URL */\n anthropicApiUrl?: string;\n /** @deprecated Use \"model\" instead */\n modelName?: AnthropicMessagesModelId;\n /** Model name to use */\n model?: AnthropicMessagesModelId;\n /** Overridable Anthropic ClientOptions */\n clientOptions?: ClientOptions;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://console.anthropic.com/docs/api/reference |\n * `anthropic.messages`} that are not explicitly specified on this class.\n */\n invocationKwargs?: Kwargs;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createClient?: (options: ClientOptions) => any;\n /**\n * Options for extended thinking.\n */\n thinking?: AnthropicThinkingConfigParam;\n /**\n * Configuration for context management. See https://docs.claude.com/en/docs/build-with-claude/context-editing\n */\n contextManagement?: AnthropicContextManagementConfigParam;\n}\n/**\n * A type representing additional parameters that can be passed to the\n * Anthropic API.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Kwargs = Record<string, any>;\n/**\n * Anthropic chat model integration.\n *\n * Setup:\n * Install `@langchain/anthropic` and set an environment variable named `ANTHROPIC_API_KEY`.\n *\n * ```bash\n * npm install @langchain/anthropic\n * export ANTHROPIC_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_anthropic.ChatAnthropic.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_anthropic.ChatAnthropicCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.bind`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.bindTools([...]).withConfig({\n * stop: [\"\\n\"],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatAnthropic } from '@langchain/anthropic';\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * temperature: 0,\n * maxTokens: undefined,\n * maxRetries: 2,\n * // apiKey: \"...\",\n * // baseUrl: \"...\",\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"response_metadata\": {\n * \"id\": \"msg_01QDpd78JUHpRP6bRRNyzbW3\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null,\n * \"usage\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19\n * },\n * \"type\": \"message\",\n * \"role\": \"assistant\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 19,\n * \"total_tokens\": 44\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01N8MwoYxiKo9w4chE4gXUs4\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\"\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 1,\n * \"total_tokens\": 26\n * }\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * }\n * AIMessageChunk {\n * \"content\": \"Here\",\n * }\n * AIMessageChunk {\n * \"content\": \"'s\",\n * }\n * AIMessageChunk {\n * \"content\": \" the translation to\",\n * }\n * AIMessageChunk {\n * \"content\": \" French:\\n\\nJ\",\n * }\n * AIMessageChunk {\n * \"content\": \"'adore la programmation\",\n * }\n * AIMessageChunk {\n * \"content\": \".\",\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 0,\n * \"output_tokens\": 19,\n * \"total_tokens\": 19\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"content\": \"Here's the translation to French:\\n\\nJ'adore la programmation.\",\n * \"additional_kwargs\": {\n * \"id\": \"msg_01SBTb5zSGXfjUc7yQ8EKEEA\",\n * \"type\": \"message\",\n * \"role\": \"assistant\",\n * \"model\": \"claude-sonnet-4-5-20250929\",\n * \"stop_reason\": \"end_turn\",\n * \"stop_sequence\": null\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 25,\n * \"output_tokens\": 20,\n * \"total_tokens\": 45\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_01WjW3Dann6BPJVtLhovdBD5',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01G6wfJgqi5zRmJomsmkyZXe',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * id: 'toolu_0165qYWBA2VFyUst5RA18zew',\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * id: 'toolu_01PGNyP33vxr13tGqr7i3rDo',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the jungle?\",\n * punchline: 'Too many cheetahs!',\n * rating: 7\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * The weather in this image appears to be beautiful and clear. The sky is a vibrant blue with scattered white clouds, suggesting a sunny and pleasant day. The clouds are wispy and light, indicating calm conditions without any signs of storms or heavy weather. The bright green grass on the rolling hills looks lush and well-watered, which could mean recent rainfall or good growing conditions. Overall, the scene depicts a perfect spring or early summer day with mild temperatures, plenty of sunshine, and gentle breezes - ideal weather for enjoying the outdoors or for plant growth.\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 19, total_tokens: 44 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 25, output_tokens: 20, total_tokens: 45 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',\n * model: 'claude-sonnet-4-5-20250929',\n * stop_reason: 'end_turn',\n * stop_sequence: null,\n * usage: { input_tokens: 25, output_tokens: 19 },\n * type: 'message',\n * role: 'assistant'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions = ChatAnthropicCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> implements AnthropicInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): Record<string, string>;\n lc_serializable: boolean;\n anthropicApiKey?: string;\n apiKey?: string;\n apiUrl?: string;\n temperature?: number;\n topK?: number;\n topP?: number;\n maxTokens: number;\n modelName: string;\n model: string;\n invocationKwargs?: Kwargs;\n stopSequences?: string[];\n streaming: boolean;\n clientOptions: ClientOptions;\n thinking: AnthropicThinkingConfigParam;\n contextManagement?: AnthropicContextManagementConfigParam;\n // Used for non-streaming requests\n protected batchClient: Anthropic;\n // Used for streaming requests\n protected streamingClient: Anthropic;\n streamUsage: boolean;\n /**\n * Optional method that returns an initialized underlying Anthropic client.\n * Useful for accessing Anthropic models hosted on other cloud services\n * such as Google Vertex.\n */\n createClient: (options: ClientOptions) => Anthropic;\n constructor(fields?: AnthropicInput & BaseChatModelParams);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n /**\n * Formats LangChain StructuredTools to AnthropicTools.\n *\n * @param {ChatAnthropicCallOptions[\"tools\"]} tools The tools to format\n * @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.\n */\n formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions[\"tools\"]): Anthropic.Messages.ToolUnion[] | undefined;\n bindTools(tools: ChatAnthropicToolType[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): Omit<AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams, \"messages\"> & Kwargs;\n /** @ignore */\n _identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n /**\n * Get the identifying parameters for the model\n */\n identifyingParams(): {\n max_tokens: number;\n model: Anthropic.Model;\n metadata?: Anthropic.Metadata | undefined;\n service_tier?: \"auto\" | \"standard_only\" | undefined;\n stop_sequences?: string[] | undefined;\n system?: string | Anthropic.TextBlockParam[] | undefined;\n temperature?: number | undefined;\n thinking?: Anthropic.ThinkingConfigParam | undefined;\n tool_choice?: Anthropic.ToolChoice | undefined;\n tools?: Anthropic.ToolUnion[] | undefined;\n top_k?: number | undefined;\n top_p?: number | undefined;\n stream?: boolean | undefined;\n model_name: string;\n };\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _generateNonStreaming(messages: BaseMessage[], params: Omit<Anthropic.Messages.MessageCreateParamsNonStreaming | Anthropic.Messages.MessageCreateParamsStreaming, \"messages\"> & Kwargs, requestOptions: AnthropicRequestOptions): Promise<{\n generations: import(\"@langchain/core/outputs\").ChatGeneration[];\n llmOutput: {\n id: string;\n model: Anthropic.Model;\n stop_reason: Anthropic.StopReason | null;\n stop_sequence: string | null;\n usage: Anthropic.Usage;\n };\n }>;\n /** @ignore */\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n /**\n * Creates a streaming request with retry.\n * @param request The parameters for creating a completion.\n * @param options\n * @returns A streaming request.\n */\n protected createStreamWithRetry(request: AnthropicStreamingMessageCreateParams & Kwargs, options?: AnthropicRequestOptions): Promise<Stream<AnthropicMessageStreamEvent>>;\n /** @ignore */\n protected completionWithRetry(request: AnthropicMessageCreateParams & Kwargs, options: AnthropicRequestOptions): Promise<Anthropic.Message>;\n _llmType(): string;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatAnthropic({ model: \"claude-opus-4-0\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 200000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\nexport declare class ChatAnthropic extends ChatAnthropicMessages {\n}\nexport {};\n"],"mappings":";;;;;;;;;;;;;;UAWiByB,wBAAAA,SAAiChB,0BAA0BmB,KAAKF;UACrEF;;AADZ;;;EAA+F,WACnFA,CAAAA,EAKMD,mBALNC;EAAqB;;;;EAD+C,OAAA,CAAA,EAWlEG,MAXkE,CAAA,MAAA,EAAA,MAAA,CAAA;EAqBpEE;;;;EAAkE,SAAA,CAAA,EAAA,MAAA;AAI9E;;;;AA4CoB5B,KAhDR4B,wBAAAA,GAA2B7B,WAAAA,CAAU8B,KAgD7B7B,GAAAA,CAAAA,MAAAA,GAhD+C8B,WAgD/C9B,CAAAA,OAAAA,CAAAA,CAAAA;;;;AAyBIgB,UArEPS,cAAAA,CAqEOT;EAAqC;AAC5D;AA+XD;;;;EAAkH,WAAwBiB,CAAAA,EAAAA,MAAAA;EAAW;;;;;EAoB3G,IAClBjB,CAAAA,EAAAA,MAAAA;EAAqC;;;;;;;;EAoBM,IAAYjB,CAAAA,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a,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bf,uCAAuCG,SAASF,wBAAwBuC;;;oBAGvFzB,sBAAsBA,mCAAmCX,eAAeoC;;IAEvFzB,8BAA8Bf,sCAAsCG,SAASF;SACvER;YACG+C;;;cAGKC,aAAAA,SAAsBpB,qBAAqB"}
@@ -3,6 +3,7 @@ import { handleToolChoice } from "./utils/tools.js";
3
3
  import { _convertMessagesToAnthropicPayload } from "./utils/message_inputs.js";
4
4
  import { _makeMessageChunkFromAnthropicEvent, anthropicResponseToChatMessages } from "./utils/message_outputs.js";
5
5
  import { wrapAnthropicClientError } from "./utils/errors.js";
6
+ import profiles_default from "./profiles.js";
6
7
  import { Anthropic as Anthropic$1 } from "@anthropic-ai/sdk";
7
8
  import { AIMessageChunk } from "@langchain/core/messages";
8
9
  import { ChatGenerationChunk } from "@langchain/core/outputs";
@@ -15,6 +16,21 @@ import { isInteropZodSchema } from "@langchain/core/utils/types";
15
16
  import { isLangChainTool } from "@langchain/core/utils/function_calling";
16
17
 
17
18
  //#region src/chat_models.ts
19
+ const MODEL_DEFAULT_MAX_OUTPUT_TOKENS = {
20
+ "claude-opus-4-1": 8192,
21
+ "claude-opus-4": 8192,
22
+ "claude-sonnet-4": 8192,
23
+ "claude-sonnet-3-7-sonnet": 8192,
24
+ "claude-3-5-sonnet": 4096,
25
+ "claude-3-5-haiku": 4096,
26
+ "claude-3-haiku": 2048
27
+ };
28
+ const FALLBACK_MAX_OUTPUT_TOKENS = 2048;
29
+ function defaultMaxOutputTokensForModel(model) {
30
+ if (!model) return FALLBACK_MAX_OUTPUT_TOKENS;
31
+ const maxTokens = Object.entries(MODEL_DEFAULT_MAX_OUTPUT_TOKENS).find(([key]) => model.startsWith(key))?.[1];
32
+ return maxTokens ?? FALLBACK_MAX_OUTPUT_TOKENS;
33
+ }
18
34
  function _toolsInParams(params) {
19
35
  return !!(params.tools && params.tools.length > 0);
20
36
  }
@@ -93,7 +109,7 @@ function extractToken(chunk) {
93
109
  * import { ChatAnthropic } from '@langchain/anthropic';
94
110
  *
95
111
  * const llm = new ChatAnthropic({
96
- * model: "claude-3-5-sonnet-20240620",
112
+ * model: "claude-sonnet-4-5-20250929",
97
113
  * temperature: 0,
98
114
  * maxTokens: undefined,
99
115
  * maxRetries: 2,
@@ -123,7 +139,7 @@ function extractToken(chunk) {
123
139
  * "content": "Here's the translation to French:\n\nJ'adore la programmation.",
124
140
  * "response_metadata": {
125
141
  * "id": "msg_01QDpd78JUHpRP6bRRNyzbW3",
126
- * "model": "claude-3-5-sonnet-20240620",
142
+ * "model": "claude-sonnet-4-5-20250929",
127
143
  * "stop_reason": "end_turn",
128
144
  * "stop_sequence": null,
129
145
  * "usage": {
@@ -161,7 +177,7 @@ function extractToken(chunk) {
161
177
  * "id": "msg_01N8MwoYxiKo9w4chE4gXUs4",
162
178
  * "type": "message",
163
179
  * "role": "assistant",
164
- * "model": "claude-3-5-sonnet-20240620"
180
+ * "model": "claude-sonnet-4-5-20250929"
165
181
  * },
166
182
  * "usage_metadata": {
167
183
  * "input_tokens": 25,
@@ -230,7 +246,7 @@ function extractToken(chunk) {
230
246
  * "id": "msg_01SBTb5zSGXfjUc7yQ8EKEEA",
231
247
  * "type": "message",
232
248
  * "role": "assistant",
233
- * "model": "claude-3-5-sonnet-20240620",
249
+ * "model": "claude-sonnet-4-5-20250929",
234
250
  * "stop_reason": "end_turn",
235
251
  * "stop_sequence": null
236
252
  * },
@@ -415,7 +431,7 @@ function extractToken(chunk) {
415
431
  * ```txt
416
432
  * {
417
433
  * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',
418
- * model: 'claude-3-5-sonnet-20240620',
434
+ * model: 'claude-sonnet-4-5-20250929',
419
435
  * stop_reason: 'end_turn',
420
436
  * stop_sequence: null,
421
437
  * usage: { input_tokens: 25, output_tokens: 19 },
@@ -444,12 +460,12 @@ var ChatAnthropicMessages = class extends BaseChatModel {
444
460
  anthropicApiKey;
445
461
  apiKey;
446
462
  apiUrl;
447
- temperature = 1;
448
- topK = -1;
449
- topP = -1;
450
- maxTokens = 2048;
451
- modelName = "claude-2.1";
452
- model = "claude-2.1";
463
+ temperature;
464
+ topK;
465
+ topP;
466
+ maxTokens;
467
+ modelName = "claude-3-5-sonnet-latest";
468
+ model = "claude-3-5-sonnet-latest";
453
469
  invocationKwargs;
454
470
  stopSequences;
455
471
  streaming = false;
@@ -477,11 +493,10 @@ var ChatAnthropicMessages = class extends BaseChatModel {
477
493
  this.modelName = fields?.model ?? fields?.modelName ?? this.model;
478
494
  this.model = this.modelName;
479
495
  this.invocationKwargs = fields?.invocationKwargs ?? {};
480
- if (this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5")) this.topP = fields?.topP === null ? void 0 : fields?.topP;
481
- else this.topP = fields?.topP ?? this.topP;
482
- this.temperature = fields?.temperature === null ? void 0 : fields?.temperature ?? this.temperature;
496
+ this.topP = fields?.topP ?? this.topP;
497
+ this.temperature = fields?.temperature ?? this.temperature;
483
498
  this.topK = fields?.topK ?? this.topK;
484
- this.maxTokens = fields?.maxTokens ?? this.maxTokens;
499
+ this.maxTokens = fields?.maxTokens ?? defaultMaxOutputTokensForModel(this.model);
485
500
  this.stopSequences = fields?.stopSequences ?? this.stopSequences;
486
501
  this.streaming = fields?.streaming ?? false;
487
502
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
@@ -536,9 +551,8 @@ var ChatAnthropicMessages = class extends BaseChatModel {
536
551
  invocationParams(options) {
537
552
  const tool_choice = handleToolChoice(options?.tool_choice);
538
553
  if (this.thinking.type === "enabled") {
539
- if (this.topK !== -1) throw new Error("topK is not supported when thinking is enabled");
540
- if (this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5") ? this.topP !== void 0 : this.topP !== -1) throw new Error("topP is not supported when thinking is enabled");
541
- if (this.temperature !== 1) throw new Error("temperature is not supported when thinking is enabled");
554
+ if (this.topP !== void 0 && this.topK !== -1) throw new Error("topK is not supported when thinking is enabled");
555
+ if (this.temperature !== void 0 && this.temperature !== 1) throw new Error("temperature is not supported when thinking is enabled");
542
556
  return {
543
557
  model: this.model,
544
558
  stop_sequences: options?.stop ?? this.stopSequences,
@@ -715,6 +729,26 @@ var ChatAnthropicMessages = class extends BaseChatModel {
715
729
  _llmType() {
716
730
  return "anthropic";
717
731
  }
732
+ /**
733
+ * Return profiling information for the model.
734
+ *
735
+ * Provides information about the model's capabilities and constraints,
736
+ * including token limits, multimodal support, and advanced features like
737
+ * tool calling and structured output.
738
+ *
739
+ * @returns {ModelProfile} An object describing the model's capabilities and constraints
740
+ *
741
+ * @example
742
+ * ```typescript
743
+ * const model = new ChatAnthropic({ model: "claude-opus-4-0" });
744
+ * const profile = model.profile;
745
+ * console.log(profile.maxInputTokens); // 200000
746
+ * console.log(profile.imageInputs); // true
747
+ * ```
748
+ */
749
+ get profile() {
750
+ return profiles_default[this.model] ?? {};
751
+ }
718
752
  withStructuredOutput(outputSchema, config) {
719
753
  const schema = outputSchema;
720
754
  const name = config?.name;
@@ -757,6 +791,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
757
791
  const thinkingAdmonition = "Anthropic structured output relies on forced tool calling, which is not supported when `thinking` is enabled. This method will raise OutputParserException if tool calls are not generated. Consider disabling `thinking` or adjust your prompt to ensure the tool is called.";
758
792
  console.warn(thinkingAdmonition);
759
793
  llm = this.withConfig({
794
+ outputVersion: "v0",
760
795
  tools,
761
796
  ls_structured_output_format: {
762
797
  kwargs: { method: "functionCalling" },
@@ -769,6 +804,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
769
804
  };
770
805
  llm = llm.pipe(raiseIfNoToolCalls);
771
806
  } else llm = this.withConfig({
807
+ outputVersion: "v0",
772
808
  tools,
773
809
  tool_choice: {
774
810
  type: "tool",