@ai-sdk/anthropic 4.0.7 → 4.0.9
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/internal/index.js
CHANGED
|
@@ -2878,7 +2878,7 @@ async function convertToAnthropicPrompt({
|
|
|
2878
2878
|
type: "tool_use",
|
|
2879
2879
|
id: part.toolCallId,
|
|
2880
2880
|
name: part.toolName,
|
|
2881
|
-
input: part.input,
|
|
2881
|
+
input: toAnthropicToolInput(part.input),
|
|
2882
2882
|
...caller && { caller },
|
|
2883
2883
|
cache_control: cacheControl
|
|
2884
2884
|
});
|
|
@@ -3278,6 +3278,9 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
3278
3278
|
flushSegment();
|
|
3279
3279
|
return result;
|
|
3280
3280
|
}
|
|
3281
|
+
function toAnthropicToolInput(input) {
|
|
3282
|
+
return typeof input === "object" && input !== null && !Array.isArray(input) ? input : { rawInvalidInput: input };
|
|
3283
|
+
}
|
|
3281
3284
|
|
|
3282
3285
|
// src/map-anthropic-stop-reason.ts
|
|
3283
3286
|
function mapAnthropicStopReason({
|
|
@@ -3697,6 +3700,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
3697
3700
|
}
|
|
3698
3701
|
const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
3699
3702
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3703
|
+
const sendThinking = isThinking || thinkingType === "disabled";
|
|
3700
3704
|
let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
|
|
3701
3705
|
const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
|
|
3702
3706
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
@@ -3710,7 +3714,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
3710
3714
|
top_p: topP,
|
|
3711
3715
|
stop_sequences: stopSequences,
|
|
3712
3716
|
// provider specific settings:
|
|
3713
|
-
...
|
|
3717
|
+
...sendThinking && {
|
|
3714
3718
|
thinking: {
|
|
3715
3719
|
type: thinkingType,
|
|
3716
3720
|
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|