@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/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "3.0.0-beta.44" : "0.0.0-test";
14
+ var VERSION = true ? "3.0.0-beta.45" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -625,7 +625,16 @@ var anthropicProviderOptions = z3.object({
625
625
  version: z3.string().optional()
626
626
  })
627
627
  ).optional()
628
- }).optional()
628
+ }).optional(),
629
+ /**
630
+ * Whether to enable tool streaming (and structured output streaming).
631
+ *
632
+ * When set to false, the model will return all tool calls and results
633
+ * at once after a delay.
634
+ *
635
+ * @default true
636
+ */
637
+ toolStreaming: z3.boolean().optional()
629
638
  });
630
639
 
631
640
  // src/anthropic-prepare-tools.ts
@@ -1899,9 +1908,10 @@ var AnthropicMessagesLanguageModel = class {
1899
1908
  seed,
1900
1909
  tools,
1901
1910
  toolChoice,
1902
- providerOptions
1911
+ providerOptions,
1912
+ stream
1903
1913
  }) {
1904
- var _a, _b, _c, _d;
1914
+ var _a, _b, _c, _d, _e;
1905
1915
  const warnings = [];
1906
1916
  if (frequencyPenalty != null) {
1907
1917
  warnings.push({
@@ -2051,6 +2061,9 @@ var AnthropicMessagesLanguageModel = class {
2051
2061
  });
2052
2062
  }
2053
2063
  }
2064
+ if (stream && ((_e = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _e : true)) {
2065
+ betas.add("fine-grained-tool-streaming-2025-05-14");
2066
+ }
2054
2067
  const {
2055
2068
  tools: anthropicTools2,
2056
2069
  toolChoice: anthropicToolChoice,
@@ -2074,7 +2087,9 @@ var AnthropicMessagesLanguageModel = class {
2074
2087
  args: {
2075
2088
  ...baseArgs,
2076
2089
  tools: anthropicTools2,
2077
- tool_choice: anthropicToolChoice
2090
+ tool_choice: anthropicToolChoice,
2091
+ stream: stream === true ? true : void 0
2092
+ // do not send when not streaming
2078
2093
  },
2079
2094
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2080
2095
  betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
@@ -2124,7 +2139,10 @@ var AnthropicMessagesLanguageModel = class {
2124
2139
  }
2125
2140
  async doGenerate(options) {
2126
2141
  var _a, _b, _c, _d, _e, _f, _g, _h;
2127
- const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
2142
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
2143
+ ...options,
2144
+ stream: false
2145
+ });
2128
2146
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2129
2147
  const {
2130
2148
  responseHeaders,
@@ -2425,9 +2443,16 @@ var AnthropicMessagesLanguageModel = class {
2425
2443
  };
2426
2444
  }
2427
2445
  async doStream(options) {
2428
- const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
2446
+ const {
2447
+ args: body,
2448
+ warnings,
2449
+ betas,
2450
+ usesJsonResponseTool
2451
+ } = await this.getArgs({
2452
+ ...options,
2453
+ stream: true
2454
+ });
2429
2455
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2430
- const body = { ...args, stream: true };
2431
2456
  const { responseHeaders, value: response } = await postJsonToApi({
2432
2457
  url: this.buildRequestUrl(true),
2433
2458
  headers: await this.getHeaders({ betas, headers: options.headers }),