@ai-sdk/anthropic 3.0.0-beta.44 → 3.0.0-beta.45
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +32 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +32 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.mjs
CHANGED
|
@@ -610,7 +610,16 @@ var anthropicProviderOptions = z3.object({
|
|
|
610
610
|
version: z3.string().optional()
|
|
611
611
|
})
|
|
612
612
|
).optional()
|
|
613
|
-
}).optional()
|
|
613
|
+
}).optional(),
|
|
614
|
+
/**
|
|
615
|
+
* Whether to enable tool streaming (and structured output streaming).
|
|
616
|
+
*
|
|
617
|
+
* When set to false, the model will return all tool calls and results
|
|
618
|
+
* at once after a delay.
|
|
619
|
+
*
|
|
620
|
+
* @default true
|
|
621
|
+
*/
|
|
622
|
+
toolStreaming: z3.boolean().optional()
|
|
614
623
|
});
|
|
615
624
|
|
|
616
625
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1884,9 +1893,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1884
1893
|
seed,
|
|
1885
1894
|
tools,
|
|
1886
1895
|
toolChoice,
|
|
1887
|
-
providerOptions
|
|
1896
|
+
providerOptions,
|
|
1897
|
+
stream
|
|
1888
1898
|
}) {
|
|
1889
|
-
var _a, _b, _c, _d;
|
|
1899
|
+
var _a, _b, _c, _d, _e;
|
|
1890
1900
|
const warnings = [];
|
|
1891
1901
|
if (frequencyPenalty != null) {
|
|
1892
1902
|
warnings.push({
|
|
@@ -2036,6 +2046,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2036
2046
|
});
|
|
2037
2047
|
}
|
|
2038
2048
|
}
|
|
2049
|
+
if (stream && ((_e = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _e : true)) {
|
|
2050
|
+
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
2051
|
+
}
|
|
2039
2052
|
const {
|
|
2040
2053
|
tools: anthropicTools2,
|
|
2041
2054
|
toolChoice: anthropicToolChoice,
|
|
@@ -2059,7 +2072,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2059
2072
|
args: {
|
|
2060
2073
|
...baseArgs,
|
|
2061
2074
|
tools: anthropicTools2,
|
|
2062
|
-
tool_choice: anthropicToolChoice
|
|
2075
|
+
tool_choice: anthropicToolChoice,
|
|
2076
|
+
stream: stream === true ? true : void 0
|
|
2077
|
+
// do not send when not streaming
|
|
2063
2078
|
},
|
|
2064
2079
|
warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
|
|
2065
2080
|
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
|
|
@@ -2109,7 +2124,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2109
2124
|
}
|
|
2110
2125
|
async doGenerate(options) {
|
|
2111
2126
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2112
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(
|
|
2127
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2128
|
+
...options,
|
|
2129
|
+
stream: false
|
|
2130
|
+
});
|
|
2113
2131
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2114
2132
|
const {
|
|
2115
2133
|
responseHeaders,
|
|
@@ -2410,9 +2428,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2410
2428
|
};
|
|
2411
2429
|
}
|
|
2412
2430
|
async doStream(options) {
|
|
2413
|
-
const {
|
|
2431
|
+
const {
|
|
2432
|
+
args: body,
|
|
2433
|
+
warnings,
|
|
2434
|
+
betas,
|
|
2435
|
+
usesJsonResponseTool
|
|
2436
|
+
} = await this.getArgs({
|
|
2437
|
+
...options,
|
|
2438
|
+
stream: true
|
|
2439
|
+
});
|
|
2414
2440
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2415
|
-
const body = { ...args, stream: true };
|
|
2416
2441
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
2417
2442
|
url: this.buildRequestUrl(true),
|
|
2418
2443
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|