@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/internal/index.mjs
CHANGED
|
@@ -1772,6 +1772,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1772
1772
|
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
1773
1773
|
}
|
|
1774
1774
|
async getArgs({
|
|
1775
|
+
userSuppliedBetas,
|
|
1775
1776
|
prompt,
|
|
1776
1777
|
maxOutputTokens,
|
|
1777
1778
|
temperature,
|
|
@@ -1989,7 +1990,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1989
1990
|
tool_choice: anthropicToolChoice
|
|
1990
1991
|
},
|
|
1991
1992
|
warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
|
|
1992
|
-
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
|
|
1993
|
+
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
|
|
1993
1994
|
usesJsonResponseTool: jsonResponseTool != null
|
|
1994
1995
|
};
|
|
1995
1996
|
}
|
|
@@ -1999,8 +2000,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1999
2000
|
}) {
|
|
2000
2001
|
return combineHeaders(
|
|
2001
2002
|
await resolve(this.config.headers),
|
|
2002
|
-
|
|
2003
|
-
|
|
2003
|
+
headers,
|
|
2004
|
+
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
2005
|
+
);
|
|
2006
|
+
}
|
|
2007
|
+
async getBetasFromHeaders(requestHeaders) {
|
|
2008
|
+
var _a, _b;
|
|
2009
|
+
const configHeaders = await resolve(this.config.headers);
|
|
2010
|
+
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
2011
|
+
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
2012
|
+
return new Set(
|
|
2013
|
+
[
|
|
2014
|
+
...configBetaHeader.toLowerCase().split(","),
|
|
2015
|
+
...requestBetaHeader.toLowerCase().split(",")
|
|
2016
|
+
].map((beta) => beta.trim()).filter((beta) => beta !== "")
|
|
2004
2017
|
);
|
|
2005
2018
|
}
|
|
2006
2019
|
buildRequestUrl(isStreaming) {
|
|
@@ -2036,7 +2049,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2036
2049
|
}
|
|
2037
2050
|
async doGenerate(options) {
|
|
2038
2051
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2039
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(
|
|
2052
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2053
|
+
...options,
|
|
2054
|
+
userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
|
|
2055
|
+
});
|
|
2040
2056
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2041
2057
|
const {
|
|
2042
2058
|
responseHeaders,
|
|
@@ -2301,7 +2317,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2301
2317
|
};
|
|
2302
2318
|
}
|
|
2303
2319
|
async doStream(options) {
|
|
2304
|
-
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(
|
|
2320
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
|
|
2321
|
+
...options,
|
|
2322
|
+
userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
|
|
2323
|
+
});
|
|
2305
2324
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2306
2325
|
const body = { ...args, stream: true };
|
|
2307
2326
|
const { responseHeaders, value: response } = await postJsonToApi({
|