@langchain/anthropic 1.0.0-alpha.2 → 1.0.0

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","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 /**\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 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;;;;EAA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cb,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"}
@@ -37,36 +37,32 @@ type AnthropicMessagesModelId = Anthropic$1.Model | (string & NonNullable<unknow
37
37
  * Input to AnthropicChat class.
38
38
  */
39
39
  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
40
+ /**
41
+ * Amount of randomness injected into the response. Ranges
42
+ * from 0 to 1. Use temperature closer to 0 for analytical /
43
+ * multiple choice, and temperature closer to 1 for creative
43
44
  * and generative tasks.
44
- * To not set this field, pass `null`. If `undefined` is passed,
45
- * the default (1) will be used.
46
45
  */
47
- temperature?: number | null;
48
- /** Only sample from the top K options for each subsequent
46
+ temperature?: number;
47
+ /**
48
+ * Only sample from the top K options for each subsequent
49
49
  * token. Used to remove "long tail" low probability
50
- * responses. Defaults to -1, which disables it.
50
+ * responses.
51
51
  */
52
52
  topK?: number;
53
- /** Does nucleus sampling, in which we compute the
53
+ /**
54
+ * Does nucleus sampling, in which we compute the
54
55
  * cumulative distribution over all the options for each
55
56
  * subsequent token in decreasing probability order and
56
57
  * 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`.
58
+ * specified by top_p. Note that you should either alter
59
+ * temperature or top_p, but not both.
65
60
  */
66
61
  topP?: number | null;
67
62
  /** A maximum number of tokens to generate before stopping. */
68
63
  maxTokens?: number;
69
- /** A list of strings upon which to stop generating.
64
+ /**
65
+ * A list of strings upon which to stop generating.
70
66
  * You probably want `["\n\nHuman:"]`, as that's the cue for
71
67
  * the next turn in the dialog agent.
72
68
  */
@@ -159,7 +155,7 @@ type Kwargs = Record<string, any>;
159
155
  * import { ChatAnthropic } from '@langchain/anthropic';
160
156
  *
161
157
  * const llm = new ChatAnthropic({
162
- * model: "claude-3-5-sonnet-20240620",
158
+ * model: "claude-sonnet-4-5-20250929",
163
159
  * temperature: 0,
164
160
  * maxTokens: undefined,
165
161
  * maxRetries: 2,
@@ -189,7 +185,7 @@ type Kwargs = Record<string, any>;
189
185
  * "content": "Here's the translation to French:\n\nJ'adore la programmation.",
190
186
  * "response_metadata": {
191
187
  * "id": "msg_01QDpd78JUHpRP6bRRNyzbW3",
192
- * "model": "claude-3-5-sonnet-20240620",
188
+ * "model": "claude-sonnet-4-5-20250929",
193
189
  * "stop_reason": "end_turn",
194
190
  * "stop_sequence": null,
195
191
  * "usage": {
@@ -227,7 +223,7 @@ type Kwargs = Record<string, any>;
227
223
  * "id": "msg_01N8MwoYxiKo9w4chE4gXUs4",
228
224
  * "type": "message",
229
225
  * "role": "assistant",
230
- * "model": "claude-3-5-sonnet-20240620"
226
+ * "model": "claude-sonnet-4-5-20250929"
231
227
  * },
232
228
  * "usage_metadata": {
233
229
  * "input_tokens": 25,
@@ -296,7 +292,7 @@ type Kwargs = Record<string, any>;
296
292
  * "id": "msg_01SBTb5zSGXfjUc7yQ8EKEEA",
297
293
  * "type": "message",
298
294
  * "role": "assistant",
299
- * "model": "claude-3-5-sonnet-20240620",
295
+ * "model": "claude-sonnet-4-5-20250929",
300
296
  * "stop_reason": "end_turn",
301
297
  * "stop_sequence": null
302
298
  * },
@@ -481,7 +477,7 @@ type Kwargs = Record<string, any>;
481
477
  * ```txt
482
478
  * {
483
479
  * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',
484
- * model: 'claude-3-5-sonnet-20240620',
480
+ * model: 'claude-sonnet-4-5-20250929',
485
481
  * stop_reason: 'end_turn',
486
482
  * stop_sequence: null,
487
483
  * usage: { input_tokens: 25, output_tokens: 19 },
@@ -503,9 +499,9 @@ declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCallOptions
503
499
  anthropicApiKey?: string;
504
500
  apiKey?: string;
505
501
  apiUrl?: string;
506
- temperature: number | undefined;
507
- topK: number;
508
- topP: number | undefined;
502
+ temperature?: number;
503
+ topK?: number;
504
+ topP?: number;
509
505
  maxTokens: number;
510
506
  modelName: string;
511
507
  model: string;
@@ -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,aA4e0HK;EAAmB;;;;EAEG,gBAAzG+B,CAAAA,EAzepCN,M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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","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 /**\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 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;;;;AA4CoB3B,KAhDR2B,wBAAAA,GAA2B5B,WAAAA,CAAU6B,KAgD7B5B,GAAAA,CAAAA,MAAAA,GAhD+C6B,WAgD/C7B,CAAAA,OAAAA,CAAAA,CAAAA;;;;AAyBIe,UArEPS,cAAAA,CAqEOT;EAAqC;AAC5D;AA+XD;;;;EAAkH,WAAwBiB,CAAAA,EAAAA,MAAAA;EAAW;;;;;EAoB3G,IAClBjB,CAAAA,EAAAA,MAAAA;EAAqC;;;;;;;;EAoBM,IAAYhB,CAAAA,EAAAA,MAAAA,GAAUkC,IAAAA;EAAkB;EACjE,SAAqBD,CAAAA,EAAAA,MAAAA;EAAW;;;;;EAAY,aAItBhB,CAAAA,EAAAA,MAAAA,EAAAA;EAA4B;EAAwC,SAAzEoB,CAAAA,EAAAA,OAAAA;EAAI;EAA2F,eAIjIR,CAAAA,EAAAA,MAAAA;EAAK;EACO,MAGX7B,CAAAA,EAAAA,MAAUuC;EAAc;EAEF,eAChBE,CAAAA,EAAAA,MAAAA;EAAU;EACP,SAWpBzC,CAAAA,EAleC4B,wBAkeSC;EAAK;EACO,KAGX7B,CAAA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DAIpEI,KAAKpB,+BAA+BG,qDAAqDW;;;;WAIrI/B,WAAAA,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"}
@@ -15,6 +15,21 @@ import { isInteropZodSchema } from "@langchain/core/utils/types";
15
15
  import { isLangChainTool } from "@langchain/core/utils/function_calling";
16
16
 
17
17
  //#region src/chat_models.ts
18
+ const MODEL_DEFAULT_MAX_OUTPUT_TOKENS = {
19
+ "claude-opus-4-1": 8192,
20
+ "claude-opus-4": 8192,
21
+ "claude-sonnet-4": 8192,
22
+ "claude-sonnet-3-7-sonnet": 8192,
23
+ "claude-3-5-sonnet": 4096,
24
+ "claude-3-5-haiku": 4096,
25
+ "claude-3-haiku": 2048
26
+ };
27
+ const FALLBACK_MAX_OUTPUT_TOKENS = 2048;
28
+ function defaultMaxOutputTokensForModel(model) {
29
+ if (!model) return FALLBACK_MAX_OUTPUT_TOKENS;
30
+ const maxTokens = Object.entries(MODEL_DEFAULT_MAX_OUTPUT_TOKENS).find(([key]) => model.startsWith(key))?.[1];
31
+ return maxTokens ?? FALLBACK_MAX_OUTPUT_TOKENS;
32
+ }
18
33
  function _toolsInParams(params) {
19
34
  return !!(params.tools && params.tools.length > 0);
20
35
  }
@@ -93,7 +108,7 @@ function extractToken(chunk) {
93
108
  * import { ChatAnthropic } from '@langchain/anthropic';
94
109
  *
95
110
  * const llm = new ChatAnthropic({
96
- * model: "claude-3-5-sonnet-20240620",
111
+ * model: "claude-sonnet-4-5-20250929",
97
112
  * temperature: 0,
98
113
  * maxTokens: undefined,
99
114
  * maxRetries: 2,
@@ -123,7 +138,7 @@ function extractToken(chunk) {
123
138
  * "content": "Here's the translation to French:\n\nJ'adore la programmation.",
124
139
  * "response_metadata": {
125
140
  * "id": "msg_01QDpd78JUHpRP6bRRNyzbW3",
126
- * "model": "claude-3-5-sonnet-20240620",
141
+ * "model": "claude-sonnet-4-5-20250929",
127
142
  * "stop_reason": "end_turn",
128
143
  * "stop_sequence": null,
129
144
  * "usage": {
@@ -161,7 +176,7 @@ function extractToken(chunk) {
161
176
  * "id": "msg_01N8MwoYxiKo9w4chE4gXUs4",
162
177
  * "type": "message",
163
178
  * "role": "assistant",
164
- * "model": "claude-3-5-sonnet-20240620"
179
+ * "model": "claude-sonnet-4-5-20250929"
165
180
  * },
166
181
  * "usage_metadata": {
167
182
  * "input_tokens": 25,
@@ -230,7 +245,7 @@ function extractToken(chunk) {
230
245
  * "id": "msg_01SBTb5zSGXfjUc7yQ8EKEEA",
231
246
  * "type": "message",
232
247
  * "role": "assistant",
233
- * "model": "claude-3-5-sonnet-20240620",
248
+ * "model": "claude-sonnet-4-5-20250929",
234
249
  * "stop_reason": "end_turn",
235
250
  * "stop_sequence": null
236
251
  * },
@@ -415,7 +430,7 @@ function extractToken(chunk) {
415
430
  * ```txt
416
431
  * {
417
432
  * id: 'msg_01STxeQxJmp4sCSpioD6vK3L',
418
- * model: 'claude-3-5-sonnet-20240620',
433
+ * model: 'claude-sonnet-4-5-20250929',
419
434
  * stop_reason: 'end_turn',
420
435
  * stop_sequence: null,
421
436
  * usage: { input_tokens: 25, output_tokens: 19 },
@@ -444,12 +459,12 @@ var ChatAnthropicMessages = class extends BaseChatModel {
444
459
  anthropicApiKey;
445
460
  apiKey;
446
461
  apiUrl;
447
- temperature = 1;
448
- topK = -1;
449
- topP = -1;
450
- maxTokens = 2048;
451
- modelName = "claude-2.1";
452
- model = "claude-2.1";
462
+ temperature;
463
+ topK;
464
+ topP;
465
+ maxTokens;
466
+ modelName = "claude-3-5-sonnet-latest";
467
+ model = "claude-3-5-sonnet-latest";
453
468
  invocationKwargs;
454
469
  stopSequences;
455
470
  streaming = false;
@@ -477,11 +492,10 @@ var ChatAnthropicMessages = class extends BaseChatModel {
477
492
  this.modelName = fields?.model ?? fields?.modelName ?? this.model;
478
493
  this.model = this.modelName;
479
494
  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;
495
+ this.topP = fields?.topP ?? this.topP;
496
+ this.temperature = fields?.temperature ?? this.temperature;
483
497
  this.topK = fields?.topK ?? this.topK;
484
- this.maxTokens = fields?.maxTokens ?? this.maxTokens;
498
+ this.maxTokens = fields?.maxTokens ?? defaultMaxOutputTokensForModel(this.model);
485
499
  this.stopSequences = fields?.stopSequences ?? this.stopSequences;
486
500
  this.streaming = fields?.streaming ?? false;
487
501
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
@@ -536,9 +550,8 @@ var ChatAnthropicMessages = class extends BaseChatModel {
536
550
  invocationParams(options) {
537
551
  const tool_choice = handleToolChoice(options?.tool_choice);
538
552
  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");
553
+ if (this.topP !== void 0 && this.topK !== -1) throw new Error("topK is not supported when thinking is enabled");
554
+ if (this.temperature !== void 0 && this.temperature !== 1) throw new Error("temperature is not supported when thinking is enabled");
542
555
  return {
543
556
  model: this.model,
544
557
  stop_sequences: options?.stop ?? this.stopSequences,
@@ -757,6 +770,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
757
770
  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
771
  console.warn(thinkingAdmonition);
759
772
  llm = this.withConfig({
773
+ outputVersion: "v0",
760
774
  tools,
761
775
  ls_structured_output_format: {
762
776
  kwargs: { method: "functionCalling" },
@@ -769,6 +783,7 @@ var ChatAnthropicMessages = class extends BaseChatModel {
769
783
  };
770
784
  llm = llm.pipe(raiseIfNoToolCalls);
771
785
  } else llm = this.withConfig({
786
+ outputVersion: "v0",
772
787
  tools,
773
788
  tool_choice: {
774
789
  type: "tool",