@ai-sdk/anthropic 2.0.66 → 2.0.68

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 ? "2.0.66" : "0.0.0-test";
14
+ var VERSION = true ? "2.0.68" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -743,7 +743,12 @@ var anthropicProviderOptions = z3.object({
743
743
  })
744
744
  ])
745
745
  )
746
- }).optional()
746
+ }).optional(),
747
+ /**
748
+ * A set of beta features to enable.
749
+ * Allow a provider to receive the full `betas` set if it needs it.
750
+ */
751
+ anthropicBeta: z3.array(z3.string()).optional()
747
752
  });
748
753
 
749
754
  // src/anthropic-prepare-tools.ts
@@ -1961,7 +1966,7 @@ var AnthropicMessagesLanguageModel = class {
1961
1966
  toolChoice,
1962
1967
  providerOptions
1963
1968
  }) {
1964
- var _a, _b, _c, _d, _e;
1969
+ var _a, _b, _c, _d, _e, _f;
1965
1970
  const warnings = [];
1966
1971
  if (frequencyPenalty != null) {
1967
1972
  warnings.push({
@@ -2062,6 +2067,9 @@ var AnthropicMessagesLanguageModel = class {
2062
2067
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
2063
2068
  speed: anthropicOptions.speed
2064
2069
  },
2070
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2071
+ cache_control: anthropicOptions.cacheControl
2072
+ },
2065
2073
  // structured output:
2066
2074
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2067
2075
  output_format: {
@@ -2232,7 +2240,12 @@ var AnthropicMessagesLanguageModel = class {
2232
2240
  tool_choice: anthropicToolChoice
2233
2241
  },
2234
2242
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2235
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
2243
+ betas: /* @__PURE__ */ new Set([
2244
+ ...betas,
2245
+ ...toolsBetas,
2246
+ ...userSuppliedBetas,
2247
+ ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2248
+ ]),
2236
2249
  usesJsonResponseTool: jsonResponseTool != null
2237
2250
  };
2238
2251
  }
@@ -2262,9 +2275,9 @@ var AnthropicMessagesLanguageModel = class {
2262
2275
  var _a, _b, _c;
2263
2276
  return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
2264
2277
  }
2265
- transformRequestBody(args) {
2278
+ transformRequestBody(args, betas) {
2266
2279
  var _a, _b, _c;
2267
- return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
2280
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args, betas)) != null ? _c : args;
2268
2281
  }
2269
2282
  extractCitationDocuments(prompt) {
2270
2283
  const isCitationPart = (part) => {
@@ -2303,7 +2316,7 @@ var AnthropicMessagesLanguageModel = class {
2303
2316
  } = await postJsonToApi({
2304
2317
  url: this.buildRequestUrl(false),
2305
2318
  headers: await this.getHeaders({ betas, headers: options.headers }),
2306
- body: this.transformRequestBody(args),
2319
+ body: this.transformRequestBody(args, betas),
2307
2320
  failedResponseHandler: anthropicFailedResponseHandler,
2308
2321
  successfulResponseHandler: createJsonResponseHandler(
2309
2322
  anthropicMessagesResponseSchema
@@ -2628,7 +2641,7 @@ var AnthropicMessagesLanguageModel = class {
2628
2641
  const { responseHeaders, value: response } = await postJsonToApi({
2629
2642
  url,
2630
2643
  headers: await this.getHeaders({ betas, headers: options.headers }),
2631
- body: this.transformRequestBody(body),
2644
+ body: this.transformRequestBody(body, betas),
2632
2645
  failedResponseHandler: anthropicFailedResponseHandler,
2633
2646
  successfulResponseHandler: createEventSourceResponseHandler(
2634
2647
  anthropicMessagesChunkSchema