@ai-sdk/anthropic 4.0.0-beta.27 → 4.0.0-beta.29
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 +25 -0
- package/dist/index.js +38 -25
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +11 -3
- package/dist/internal/index.js +37 -24
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-messages-language-model.ts +25 -4
- package/src/convert-to-anthropic-messages-prompt.ts +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [add1126]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
9
|
+
|
|
10
|
+
## 4.0.0-beta.28
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
15
|
+
|
|
16
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
17
|
+
|
|
18
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
19
|
+
|
|
20
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
21
|
+
|
|
22
|
+
- ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
|
|
23
|
+
- Updated dependencies [b3976a2]
|
|
24
|
+
- Updated dependencies [ff5eba1]
|
|
25
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
26
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
27
|
+
|
|
3
28
|
## 4.0.0-beta.27
|
|
4
29
|
|
|
5
30
|
### Major Changes
|
package/dist/index.js
CHANGED
|
@@ -127,7 +127,10 @@ import {
|
|
|
127
127
|
parseProviderOptions as parseProviderOptions2,
|
|
128
128
|
postJsonToApi,
|
|
129
129
|
resolve,
|
|
130
|
-
resolveProviderReference as resolveProviderReference2
|
|
130
|
+
resolveProviderReference as resolveProviderReference2,
|
|
131
|
+
serializeModelOptions,
|
|
132
|
+
WORKFLOW_SERIALIZE,
|
|
133
|
+
WORKFLOW_DESERIALIZE
|
|
131
134
|
} from "@ai-sdk/provider-utils";
|
|
132
135
|
|
|
133
136
|
// src/anthropic-messages-api.ts
|
|
@@ -2325,26 +2328,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2325
2328
|
type: "text",
|
|
2326
2329
|
text: contentPart.text
|
|
2327
2330
|
};
|
|
2328
|
-
case "image-data": {
|
|
2329
|
-
return {
|
|
2330
|
-
type: "image",
|
|
2331
|
-
source: {
|
|
2332
|
-
type: "base64",
|
|
2333
|
-
media_type: contentPart.mediaType,
|
|
2334
|
-
data: contentPart.data
|
|
2335
|
-
}
|
|
2336
|
-
};
|
|
2337
|
-
}
|
|
2338
|
-
case "image-url": {
|
|
2339
|
-
return {
|
|
2340
|
-
type: "image",
|
|
2341
|
-
source: {
|
|
2342
|
-
type: "url",
|
|
2343
|
-
url: contentPart.url
|
|
2344
|
-
}
|
|
2345
|
-
};
|
|
2346
|
-
}
|
|
2347
2331
|
case "file-url": {
|
|
2332
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2333
|
+
return {
|
|
2334
|
+
type: "image",
|
|
2335
|
+
source: {
|
|
2336
|
+
type: "url",
|
|
2337
|
+
url: contentPart.url
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2348
2341
|
return {
|
|
2349
2342
|
type: "document",
|
|
2350
2343
|
source: {
|
|
@@ -2354,6 +2347,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2354
2347
|
};
|
|
2355
2348
|
}
|
|
2356
2349
|
case "file-data": {
|
|
2350
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2351
|
+
return {
|
|
2352
|
+
type: "image",
|
|
2353
|
+
source: {
|
|
2354
|
+
type: "base64",
|
|
2355
|
+
media_type: contentPart.mediaType,
|
|
2356
|
+
data: contentPart.data
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2357
2360
|
if (contentPart.mediaType === "application/pdf") {
|
|
2358
2361
|
betas.add("pdfs-2024-09-25");
|
|
2359
2362
|
return {
|
|
@@ -3000,7 +3003,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
3000
3003
|
}
|
|
3001
3004
|
};
|
|
3002
3005
|
}
|
|
3003
|
-
var AnthropicMessagesLanguageModel = class {
|
|
3006
|
+
var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
|
|
3004
3007
|
constructor(modelId, config) {
|
|
3005
3008
|
this.specificationVersion = "v4";
|
|
3006
3009
|
var _a;
|
|
@@ -3008,6 +3011,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3008
3011
|
this.config = config;
|
|
3009
3012
|
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3010
3013
|
}
|
|
3014
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3015
|
+
return serializeModelOptions({
|
|
3016
|
+
modelId: model.modelId,
|
|
3017
|
+
config: model.config
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3021
|
+
return new _AnthropicMessagesLanguageModel(options.modelId, options.config);
|
|
3022
|
+
}
|
|
3011
3023
|
supportsUrl(url) {
|
|
3012
3024
|
return url.protocol === "https:";
|
|
3013
3025
|
}
|
|
@@ -3430,15 +3442,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3430
3442
|
headers
|
|
3431
3443
|
}) {
|
|
3432
3444
|
return combineHeaders2(
|
|
3433
|
-
await resolve(this.config.headers),
|
|
3445
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3434
3446
|
headers,
|
|
3435
3447
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3436
3448
|
);
|
|
3437
3449
|
}
|
|
3438
3450
|
async getBetasFromHeaders(requestHeaders) {
|
|
3439
3451
|
var _a, _b;
|
|
3440
|
-
const configHeaders = await resolve(this.config.headers);
|
|
3441
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3452
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3453
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3442
3454
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3443
3455
|
return new Set(
|
|
3444
3456
|
[
|
|
@@ -3902,6 +3914,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3902
3914
|
};
|
|
3903
3915
|
}
|
|
3904
3916
|
async doStream(options) {
|
|
3917
|
+
"use step";
|
|
3905
3918
|
var _a, _b;
|
|
3906
3919
|
const {
|
|
3907
3920
|
args: body,
|
|
@@ -5472,7 +5485,7 @@ var AnthropicSkills = class {
|
|
|
5472
5485
|
};
|
|
5473
5486
|
|
|
5474
5487
|
// src/version.ts
|
|
5475
|
-
var VERSION = true ? "4.0.0-beta.
|
|
5488
|
+
var VERSION = true ? "4.0.0-beta.29" : "0.0.0-test";
|
|
5476
5489
|
|
|
5477
5490
|
// src/anthropic-provider.ts
|
|
5478
5491
|
function createAnthropic(options = {}) {
|