Skip to content

Commit e4343e6

Browse files
yu-iskwchristian-bromann
authored andcommitted
feat(langchain-anthropic): introduce ChatAnthropicInput type for improved constructor typing (#9588)
Signed-off-by: Yu Ishikawa <[email protected]>
1 parent 5732405 commit e4343e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@langchain/anthropic": minor
3+
---
4+
5+
Expose `ChatAnthropicInput` type for improved type safety and user experience.
6+
7+
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.

libs/providers/langchain-anthropic/src/chat_models.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ export interface AnthropicInput {
300300
betas?: AnthropicBeta[];
301301
}
302302

303+
/**
304+
* Input to ChatAnthropic class.
305+
*/
306+
export type ChatAnthropicInput = AnthropicInput & BaseChatModelParams;
307+
303308
function extractToken(chunk: AIMessageChunk): string | undefined {
304309
if (typeof chunk.content === "string") {
305310
return chunk.content;
@@ -910,7 +915,7 @@ export class ChatAnthropicMessages<
910915
*/
911916
createClient: (options: ClientOptions) => Anthropic;
912917

913-
constructor(fields?: AnthropicInput & BaseChatModelParams) {
918+
constructor(fields?: ChatAnthropicInput) {
914919
super(fields ?? {});
915920

916921
this.anthropicApiKey =

0 commit comments

Comments
 (0)