@langchain/anthropic 0.3.25 → 0.3.26
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.
- package/dist/chat_models.cjs +13 -2
- package/dist/chat_models.d.ts +11 -4
- package/dist/chat_models.js +13 -2
- package/package.json +1 -1
package/dist/chat_models.cjs
CHANGED
|
@@ -608,9 +608,20 @@ class ChatAnthropicMessages extends chat_models_1.BaseChatModel {
|
|
|
608
608
|
this.modelName = fields?.model ?? fields?.modelName ?? this.model;
|
|
609
609
|
this.model = this.modelName;
|
|
610
610
|
this.invocationKwargs = fields?.invocationKwargs ?? {};
|
|
611
|
-
this.
|
|
611
|
+
if (this.model.includes("opus-4-1")) {
|
|
612
|
+
// Default to `undefined` for `topP` for Opus 4.1 models
|
|
613
|
+
this.topP = fields?.topP === null ? undefined : fields?.topP;
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
this.topP = fields?.topP ?? this.topP;
|
|
617
|
+
}
|
|
618
|
+
// If the user passes `null`, set it to `undefined`. Otherwise, use their value or the default. We have to check for null, because
|
|
619
|
+
// there's no way for us to know if they explicitly set it to `undefined`, or never passed a value
|
|
620
|
+
this.temperature =
|
|
621
|
+
fields?.temperature === null
|
|
622
|
+
? undefined
|
|
623
|
+
: fields?.temperature ?? this.temperature;
|
|
612
624
|
this.topK = fields?.topK ?? this.topK;
|
|
613
|
-
this.topP = fields?.topP ?? this.topP;
|
|
614
625
|
this.maxTokens =
|
|
615
626
|
fields?.maxTokensToSample ?? fields?.maxTokens ?? this.maxTokens;
|
|
616
627
|
this.stopSequences = fields?.stopSequences ?? this.stopSequences;
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -33,8 +33,10 @@ export interface AnthropicInput {
|
|
|
33
33
|
* from 0 to 1. Use temp closer to 0 for analytical /
|
|
34
34
|
* multiple choice, and temp closer to 1 for creative
|
|
35
35
|
* and generative tasks.
|
|
36
|
+
* To not set this field, pass `null`. If `undefined` is passed,
|
|
37
|
+
* the default (1) will be used.
|
|
36
38
|
*/
|
|
37
|
-
temperature?: number;
|
|
39
|
+
temperature?: number | null;
|
|
38
40
|
/** Only sample from the top K options for each subsequent
|
|
39
41
|
* token. Used to remove "long tail" low probability
|
|
40
42
|
* responses. Defaults to -1, which disables it.
|
|
@@ -47,8 +49,13 @@ export interface AnthropicInput {
|
|
|
47
49
|
* specified by top_p. Defaults to -1, which disables it.
|
|
48
50
|
* Note that you should either alter temperature or top_p,
|
|
49
51
|
* but not both.
|
|
52
|
+
*
|
|
53
|
+
* To not set this field, pass `null`. If `undefined` is passed,
|
|
54
|
+
* the default (-1) will be used.
|
|
55
|
+
*
|
|
56
|
+
* For Opus 4.1, this defaults to `null`.
|
|
50
57
|
*/
|
|
51
|
-
topP?: number;
|
|
58
|
+
topP?: number | null;
|
|
52
59
|
/** A maximum number of tokens to generate before stopping. */
|
|
53
60
|
maxTokens?: number;
|
|
54
61
|
/**
|
|
@@ -487,9 +494,9 @@ export declare class ChatAnthropicMessages<CallOptions extends ChatAnthropicCall
|
|
|
487
494
|
anthropicApiKey?: string;
|
|
488
495
|
apiKey?: string;
|
|
489
496
|
apiUrl?: string;
|
|
490
|
-
temperature: number;
|
|
497
|
+
temperature: number | undefined;
|
|
491
498
|
topK: number;
|
|
492
|
-
topP: number;
|
|
499
|
+
topP: number | undefined;
|
|
493
500
|
maxTokens: number;
|
|
494
501
|
modelName: string;
|
|
495
502
|
model: string;
|
package/dist/chat_models.js
CHANGED
|
@@ -605,9 +605,20 @@ export class ChatAnthropicMessages extends BaseChatModel {
|
|
|
605
605
|
this.modelName = fields?.model ?? fields?.modelName ?? this.model;
|
|
606
606
|
this.model = this.modelName;
|
|
607
607
|
this.invocationKwargs = fields?.invocationKwargs ?? {};
|
|
608
|
-
this.
|
|
608
|
+
if (this.model.includes("opus-4-1")) {
|
|
609
|
+
// Default to `undefined` for `topP` for Opus 4.1 models
|
|
610
|
+
this.topP = fields?.topP === null ? undefined : fields?.topP;
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
this.topP = fields?.topP ?? this.topP;
|
|
614
|
+
}
|
|
615
|
+
// If the user passes `null`, set it to `undefined`. Otherwise, use their value or the default. We have to check for null, because
|
|
616
|
+
// there's no way for us to know if they explicitly set it to `undefined`, or never passed a value
|
|
617
|
+
this.temperature =
|
|
618
|
+
fields?.temperature === null
|
|
619
|
+
? undefined
|
|
620
|
+
: fields?.temperature ?? this.temperature;
|
|
609
621
|
this.topK = fields?.topK ?? this.topK;
|
|
610
|
-
this.topP = fields?.topP ?? this.topP;
|
|
611
622
|
this.maxTokens =
|
|
612
623
|
fields?.maxTokensToSample ?? fields?.maxTokens ?? this.maxTokens;
|
|
613
624
|
this.stopSequences = fields?.stopSequences ?? this.stopSequences;
|