@ai-sdk/anthropic 2.0.48 → 2.0.49
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.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +24 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +24 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
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.
|
|
14
|
+
var VERSION = true ? "2.0.49" : "0.0.0-test";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-messages-language-model.ts
|
|
17
17
|
import {
|
|
@@ -1787,6 +1787,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1787
1787
|
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
1788
1788
|
}
|
|
1789
1789
|
async getArgs({
|
|
1790
|
+
userSuppliedBetas,
|
|
1790
1791
|
prompt,
|
|
1791
1792
|
maxOutputTokens,
|
|
1792
1793
|
temperature,
|
|
@@ -2004,7 +2005,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2004
2005
|
tool_choice: anthropicToolChoice
|
|
2005
2006
|
},
|
|
2006
2007
|
warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
|
|
2007
|
-
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
|
|
2008
|
+
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
|
|
2008
2009
|
usesJsonResponseTool: jsonResponseTool != null
|
|
2009
2010
|
};
|
|
2010
2011
|
}
|
|
@@ -2014,8 +2015,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2014
2015
|
}) {
|
|
2015
2016
|
return combineHeaders(
|
|
2016
2017
|
await resolve(this.config.headers),
|
|
2017
|
-
|
|
2018
|
-
|
|
2018
|
+
headers,
|
|
2019
|
+
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
async getBetasFromHeaders(requestHeaders) {
|
|
2023
|
+
var _a, _b;
|
|
2024
|
+
const configHeaders = await resolve(this.config.headers);
|
|
2025
|
+
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
2026
|
+
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
2027
|
+
return new Set(
|
|
2028
|
+
[
|
|
2029
|
+
...configBetaHeader.toLowerCase().split(","),
|
|
2030
|
+
...requestBetaHeader.toLowerCase().split(",")
|
|
2031
|
+
].map((beta) => beta.trim()).filter((beta) => beta !== "")
|
|
2019
2032
|
);
|
|
2020
2033
|
}
|
|
2021
2034
|
buildRequestUrl(isStreaming) {
|
|
@@ -2051,7 +2064,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2051
2064
|
}
|
|
2052
2065
|
async doGenerate(options) {
|
|
2053
2066
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2054
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(
|
|
2067
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2068
|
+
...options,
|
|
2069
|
+
userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
|
|
2070
|
+
});
|
|
2055
2071
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2056
2072
|
const {
|
|
2057
2073
|
responseHeaders,
|
|
@@ -2316,7 +2332,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2316
2332
|
};
|
|
2317
2333
|
}
|
|
2318
2334
|
async doStream(options) {
|
|
2319
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(
|
|
2335
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2336
|
+
...options,
|
|
2337
|
+
userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
|
|
2338
|
+
});
|
|
2320
2339
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2321
2340
|
const body = { ...args, stream: true };
|
|
2322
2341
|
const { responseHeaders, value: response } = await postJsonToApi({
|