ai 5.0.94 → 5.0.96
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 +14 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.96
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c89268c: fix(provider/google): preserve thoughtSignature through tool execution
|
|
8
|
+
|
|
9
|
+
## 5.0.95
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a20e687: feat(provider/gateway): add support for image models
|
|
14
|
+
- Updated dependencies [a20e687]
|
|
15
|
+
- @ai-sdk/gateway@2.0.11
|
|
16
|
+
|
|
3
17
|
## 5.0.94
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -168,7 +168,7 @@ type Embedding = EmbeddingModelV2Embedding;
|
|
|
168
168
|
/**
|
|
169
169
|
Image model that is used by the AI SDK Core functions.
|
|
170
170
|
*/
|
|
171
|
-
type ImageModel = ImageModelV2;
|
|
171
|
+
type ImageModel = string | ImageModelV2;
|
|
172
172
|
/**
|
|
173
173
|
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
174
174
|
some settings might not be supported, which can lead to suboptimal results.
|
|
@@ -522,6 +522,7 @@ type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
|
522
522
|
input: InferToolInput<TOOLS[NAME]>;
|
|
523
523
|
error: unknown;
|
|
524
524
|
providerExecuted?: boolean;
|
|
525
|
+
providerMetadata?: ProviderMetadata;
|
|
525
526
|
dynamic?: false | undefined;
|
|
526
527
|
};
|
|
527
528
|
}>;
|
|
@@ -532,6 +533,7 @@ type DynamicToolError = {
|
|
|
532
533
|
input: unknown;
|
|
533
534
|
error: unknown;
|
|
534
535
|
providerExecuted?: boolean;
|
|
536
|
+
providerMetadata?: ProviderMetadata;
|
|
535
537
|
dynamic: true;
|
|
536
538
|
};
|
|
537
539
|
type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
|
|
@@ -544,6 +546,7 @@ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
|
|
|
544
546
|
input: InferToolInput<TOOLS[NAME]>;
|
|
545
547
|
output: InferToolOutput<TOOLS[NAME]>;
|
|
546
548
|
providerExecuted?: boolean;
|
|
549
|
+
providerMetadata?: ProviderMetadata;
|
|
547
550
|
dynamic?: false | undefined;
|
|
548
551
|
preliminary?: boolean;
|
|
549
552
|
};
|
|
@@ -555,6 +558,7 @@ type DynamicToolResult = {
|
|
|
555
558
|
input: unknown;
|
|
556
559
|
output: unknown;
|
|
557
560
|
providerExecuted?: boolean;
|
|
561
|
+
providerMetadata?: ProviderMetadata;
|
|
558
562
|
dynamic: true;
|
|
559
563
|
preliminary?: boolean;
|
|
560
564
|
};
|
|
@@ -2868,11 +2872,11 @@ as body parameters.
|
|
|
2868
2872
|
|
|
2869
2873
|
@returns A result object that contains the generated images.
|
|
2870
2874
|
*/
|
|
2871
|
-
declare function generateImage({ model, prompt, n, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, }: {
|
|
2875
|
+
declare function generateImage({ model: modelArg, prompt, n, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, }: {
|
|
2872
2876
|
/**
|
|
2873
2877
|
The image model to use.
|
|
2874
2878
|
*/
|
|
2875
|
-
model:
|
|
2879
|
+
model: ImageModel;
|
|
2876
2880
|
/**
|
|
2877
2881
|
The prompt that should be used to generate the image.
|
|
2878
2882
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ type Embedding = EmbeddingModelV2Embedding;
|
|
|
168
168
|
/**
|
|
169
169
|
Image model that is used by the AI SDK Core functions.
|
|
170
170
|
*/
|
|
171
|
-
type ImageModel = ImageModelV2;
|
|
171
|
+
type ImageModel = string | ImageModelV2;
|
|
172
172
|
/**
|
|
173
173
|
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
174
174
|
some settings might not be supported, which can lead to suboptimal results.
|
|
@@ -522,6 +522,7 @@ type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
|
522
522
|
input: InferToolInput<TOOLS[NAME]>;
|
|
523
523
|
error: unknown;
|
|
524
524
|
providerExecuted?: boolean;
|
|
525
|
+
providerMetadata?: ProviderMetadata;
|
|
525
526
|
dynamic?: false | undefined;
|
|
526
527
|
};
|
|
527
528
|
}>;
|
|
@@ -532,6 +533,7 @@ type DynamicToolError = {
|
|
|
532
533
|
input: unknown;
|
|
533
534
|
error: unknown;
|
|
534
535
|
providerExecuted?: boolean;
|
|
536
|
+
providerMetadata?: ProviderMetadata;
|
|
535
537
|
dynamic: true;
|
|
536
538
|
};
|
|
537
539
|
type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
|
|
@@ -544,6 +546,7 @@ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
|
|
|
544
546
|
input: InferToolInput<TOOLS[NAME]>;
|
|
545
547
|
output: InferToolOutput<TOOLS[NAME]>;
|
|
546
548
|
providerExecuted?: boolean;
|
|
549
|
+
providerMetadata?: ProviderMetadata;
|
|
547
550
|
dynamic?: false | undefined;
|
|
548
551
|
preliminary?: boolean;
|
|
549
552
|
};
|
|
@@ -555,6 +558,7 @@ type DynamicToolResult = {
|
|
|
555
558
|
input: unknown;
|
|
556
559
|
output: unknown;
|
|
557
560
|
providerExecuted?: boolean;
|
|
561
|
+
providerMetadata?: ProviderMetadata;
|
|
558
562
|
dynamic: true;
|
|
559
563
|
preliminary?: boolean;
|
|
560
564
|
};
|
|
@@ -2868,11 +2872,11 @@ as body parameters.
|
|
|
2868
2872
|
|
|
2869
2873
|
@returns A result object that contains the generated images.
|
|
2870
2874
|
*/
|
|
2871
|
-
declare function generateImage({ model, prompt, n, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, }: {
|
|
2875
|
+
declare function generateImage({ model: modelArg, prompt, n, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, }: {
|
|
2872
2876
|
/**
|
|
2873
2877
|
The image model to use.
|
|
2874
2878
|
*/
|
|
2875
|
-
model:
|
|
2879
|
+
model: ImageModel;
|
|
2876
2880
|
/**
|
|
2877
2881
|
The prompt that should be used to generate the image.
|
|
2878
2882
|
*/
|
package/dist/index.js
CHANGED
|
@@ -567,6 +567,19 @@ function resolveEmbeddingModel(model) {
|
|
|
567
567
|
model
|
|
568
568
|
);
|
|
569
569
|
}
|
|
570
|
+
function resolveImageModel(model) {
|
|
571
|
+
if (typeof model !== "string") {
|
|
572
|
+
if (model.specificationVersion !== "v2") {
|
|
573
|
+
throw new UnsupportedModelVersionError({
|
|
574
|
+
version: model.specificationVersion,
|
|
575
|
+
provider: model.provider,
|
|
576
|
+
modelId: model.modelId
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
return model;
|
|
580
|
+
}
|
|
581
|
+
return getGlobalProvider().imageModel(model);
|
|
582
|
+
}
|
|
570
583
|
function getGlobalProvider() {
|
|
571
584
|
var _a16;
|
|
572
585
|
return (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : import_gateway.gateway;
|
|
@@ -764,7 +777,7 @@ function detectMediaType({
|
|
|
764
777
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
765
778
|
|
|
766
779
|
// src/version.ts
|
|
767
|
-
var VERSION = true ? "5.0.
|
|
780
|
+
var VERSION = true ? "5.0.96" : "0.0.0-test";
|
|
768
781
|
|
|
769
782
|
// src/util/download/download.ts
|
|
770
783
|
var download = async ({ url }) => {
|
|
@@ -2180,7 +2193,8 @@ function toResponseMessages({
|
|
|
2180
2193
|
tool: tools == null ? void 0 : tools[toolResult.toolName],
|
|
2181
2194
|
output: toolResult.type === "tool-result" ? toolResult.output : toolResult.error,
|
|
2182
2195
|
errorMode: toolResult.type === "tool-error" ? "text" : "none"
|
|
2183
|
-
})
|
|
2196
|
+
}),
|
|
2197
|
+
...toolResult.providerMetadata != null ? { providerOptions: toolResult.providerMetadata } : {}
|
|
2184
2198
|
}));
|
|
2185
2199
|
if (toolResultContent.length > 0) {
|
|
2186
2200
|
responseMessages.push({
|
|
@@ -6436,7 +6450,7 @@ var DefaultEmbedManyResult = class {
|
|
|
6436
6450
|
// src/generate-image/generate-image.ts
|
|
6437
6451
|
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
6438
6452
|
async function generateImage({
|
|
6439
|
-
model,
|
|
6453
|
+
model: modelArg,
|
|
6440
6454
|
prompt,
|
|
6441
6455
|
n = 1,
|
|
6442
6456
|
maxImagesPerCall,
|
|
@@ -6449,13 +6463,7 @@ async function generateImage({
|
|
|
6449
6463
|
headers
|
|
6450
6464
|
}) {
|
|
6451
6465
|
var _a16, _b;
|
|
6452
|
-
|
|
6453
|
-
throw new UnsupportedModelVersionError({
|
|
6454
|
-
version: model.specificationVersion,
|
|
6455
|
-
provider: model.provider,
|
|
6456
|
-
modelId: model.modelId
|
|
6457
|
-
});
|
|
6458
|
-
}
|
|
6466
|
+
const model = resolveImageModel(modelArg);
|
|
6459
6467
|
const headersWithUserAgent = (0, import_provider_utils18.withUserAgentSuffix)(
|
|
6460
6468
|
headers != null ? headers : {},
|
|
6461
6469
|
`ai/${VERSION}`
|
|
@@ -6511,10 +6519,26 @@ async function generateImage({
|
|
|
6511
6519
|
warnings.push(...result.warnings);
|
|
6512
6520
|
if (result.providerMetadata) {
|
|
6513
6521
|
for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
|
|
6514
|
-
(
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6522
|
+
if (providerName === "gateway") {
|
|
6523
|
+
const currentEntry = providerMetadata[providerName];
|
|
6524
|
+
if (currentEntry != null && typeof currentEntry === "object") {
|
|
6525
|
+
providerMetadata[providerName] = {
|
|
6526
|
+
...currentEntry,
|
|
6527
|
+
...metadata
|
|
6528
|
+
};
|
|
6529
|
+
} else {
|
|
6530
|
+
providerMetadata[providerName] = metadata;
|
|
6531
|
+
}
|
|
6532
|
+
const imagesValue = providerMetadata[providerName].images;
|
|
6533
|
+
if (Array.isArray(imagesValue) && imagesValue.length === 0) {
|
|
6534
|
+
delete providerMetadata[providerName].images;
|
|
6535
|
+
}
|
|
6536
|
+
} else {
|
|
6537
|
+
(_b = providerMetadata[providerName]) != null ? _b : providerMetadata[providerName] = { images: [] };
|
|
6538
|
+
providerMetadata[providerName].images.push(
|
|
6539
|
+
...result.providerMetadata[providerName].images
|
|
6540
|
+
);
|
|
6541
|
+
}
|
|
6518
6542
|
}
|
|
6519
6543
|
}
|
|
6520
6544
|
responses.push(result.response);
|