@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.js
CHANGED
|
@@ -624,7 +624,16 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
624
624
|
version: import_v43.z.string().optional()
|
|
625
625
|
})
|
|
626
626
|
).optional()
|
|
627
|
-
}).optional()
|
|
627
|
+
}).optional(),
|
|
628
|
+
/**
|
|
629
|
+
* Whether to enable tool streaming (and structured output streaming).
|
|
630
|
+
*
|
|
631
|
+
* When set to false, the model will return all tool calls and results
|
|
632
|
+
* at once after a delay.
|
|
633
|
+
*
|
|
634
|
+
* @default true
|
|
635
|
+
*/
|
|
636
|
+
toolStreaming: import_v43.z.boolean().optional()
|
|
628
637
|
});
|
|
629
638
|
|
|
630
639
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1873,9 +1882,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1873
1882
|
seed,
|
|
1874
1883
|
tools,
|
|
1875
1884
|
toolChoice,
|
|
1876
|
-
providerOptions
|
|
1885
|
+
providerOptions,
|
|
1886
|
+
stream
|
|
1877
1887
|
}) {
|
|
1878
|
-
var _a, _b, _c, _d;
|
|
1888
|
+
var _a, _b, _c, _d, _e;
|
|
1879
1889
|
const warnings = [];
|
|
1880
1890
|
if (frequencyPenalty != null) {
|
|
1881
1891
|
warnings.push({
|
|
@@ -2025,6 +2035,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2025
2035
|
});
|
|
2026
2036
|
}
|
|
2027
2037
|
}
|
|
2038
|
+
if (stream && ((_e = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _e : true)) {
|
|
2039
|
+
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
2040
|
+
}
|
|
2028
2041
|
const {
|
|
2029
2042
|
tools: anthropicTools2,
|
|
2030
2043
|
toolChoice: anthropicToolChoice,
|
|
@@ -2048,7 +2061,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2048
2061
|
args: {
|
|
2049
2062
|
...baseArgs,
|
|
2050
2063
|
tools: anthropicTools2,
|
|
2051
|
-
tool_choice: anthropicToolChoice
|
|
2064
|
+
tool_choice: anthropicToolChoice,
|
|
2065
|
+
stream: stream === true ? true : void 0
|
|
2066
|
+
// do not send when not streaming
|
|
2052
2067
|
},
|
|
2053
2068
|
warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
|
|
2054
2069
|
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
|
|
@@ -2098,7 +2113,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2098
2113
|
}
|
|
2099
2114
|
async doGenerate(options) {
|
|
2100
2115
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2101
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(
|
|
2116
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2117
|
+
...options,
|
|
2118
|
+
stream: false
|
|
2119
|
+
});
|
|
2102
2120
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2103
2121
|
const {
|
|
2104
2122
|
responseHeaders,
|
|
@@ -2399,9 +2417,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2399
2417
|
};
|
|
2400
2418
|
}
|
|
2401
2419
|
async doStream(options) {
|
|
2402
|
-
const {
|
|
2420
|
+
const {
|
|
2421
|
+
args: body,
|
|
2422
|
+
warnings,
|
|
2423
|
+
betas,
|
|
2424
|
+
usesJsonResponseTool
|
|
2425
|
+
} = await this.getArgs({
|
|
2426
|
+
...options,
|
|
2427
|
+
stream: true
|
|
2428
|
+
});
|
|
2403
2429
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2404
|
-
const body = { ...args, stream: true };
|
|
2405
2430
|
const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
|
|
2406
2431
|
url: this.buildRequestUrl(true),
|
|
2407
2432
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|