diff --git a/.changeset/expose-chatanthropic-input-type.md b/.changeset/expose-chatanthropic-input-type.md new file mode 100644 index 000000000000..2863fe1a60ec --- /dev/null +++ b/.changeset/expose-chatanthropic-input-type.md @@ -0,0 +1,7 @@ +--- +"@langchain/anthropic": minor +--- + +Expose `ChatAnthropicInput` type for improved type safety and user experience. + +This change introduces a new exported type `ChatAnthropicInput` which is an intersection of `AnthropicInput` and `BaseChatModelParams`. This allows LangChain users to define and pass ChatAnthropic configuration options with full type safety and IntelliSense. diff --git a/libs/providers/langchain-anthropic/src/chat_models.ts b/libs/providers/langchain-anthropic/src/chat_models.ts index ecb102d77548..e31b6ad8ddaf 100644 --- a/libs/providers/langchain-anthropic/src/chat_models.ts +++ b/libs/providers/langchain-anthropic/src/chat_models.ts @@ -294,6 +294,11 @@ export interface AnthropicInput { betas?: AnthropicBeta[]; } +/** + * Input to ChatAnthropic class. + */ +export type ChatAnthropicInput = AnthropicInput & BaseChatModelParams; + function extractToken(chunk: AIMessageChunk): string | undefined { if (typeof chunk.content === "string") { return chunk.content; @@ -904,7 +909,7 @@ export class ChatAnthropicMessages< */ createClient: (options: ClientOptions) => Anthropic; - constructor(fields?: AnthropicInput & BaseChatModelParams) { + constructor(fields?: ChatAnthropicInput) { super(fields ?? {}); this.anthropicApiKey =