ai 6.0.0-beta.102 → 6.0.0-beta.104
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 +15 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +51 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -27
- 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/dist/index.mjs
CHANGED
|
@@ -452,6 +452,20 @@ function asEmbeddingModelV3(model) {
|
|
|
452
452
|
});
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
// src/model/as-image-model-v3.ts
|
|
456
|
+
function asImageModelV3(model) {
|
|
457
|
+
if (model.specificationVersion === "v3") {
|
|
458
|
+
return model;
|
|
459
|
+
}
|
|
460
|
+
return new Proxy(model, {
|
|
461
|
+
get(target, prop) {
|
|
462
|
+
if (prop === "specificationVersion")
|
|
463
|
+
return "v3";
|
|
464
|
+
return target[prop];
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
455
469
|
// src/model/as-language-model-v3.ts
|
|
456
470
|
function asLanguageModelV3(model) {
|
|
457
471
|
if (model.specificationVersion === "v3") {
|
|
@@ -555,6 +569,20 @@ function resolveSpeechModel(model) {
|
|
|
555
569
|
}
|
|
556
570
|
return (_b = (_a15 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a15, model);
|
|
557
571
|
}
|
|
572
|
+
function resolveImageModel(model) {
|
|
573
|
+
if (typeof model !== "string") {
|
|
574
|
+
if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
|
|
575
|
+
const unsupportedModel = model;
|
|
576
|
+
throw new UnsupportedModelVersionError({
|
|
577
|
+
version: unsupportedModel.specificationVersion,
|
|
578
|
+
provider: unsupportedModel.provider,
|
|
579
|
+
modelId: unsupportedModel.modelId
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
return asImageModelV3(model);
|
|
583
|
+
}
|
|
584
|
+
return getGlobalProvider().imageModel(model);
|
|
585
|
+
}
|
|
558
586
|
function getGlobalProvider() {
|
|
559
587
|
var _a15;
|
|
560
588
|
return (_a15 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a15 : gateway;
|
|
@@ -757,7 +785,7 @@ import {
|
|
|
757
785
|
} from "@ai-sdk/provider-utils";
|
|
758
786
|
|
|
759
787
|
// src/version.ts
|
|
760
|
-
var VERSION = true ? "6.0.0-beta.
|
|
788
|
+
var VERSION = true ? "6.0.0-beta.104" : "0.0.0-test";
|
|
761
789
|
|
|
762
790
|
// src/util/download/download.ts
|
|
763
791
|
var download = async ({ url }) => {
|
|
@@ -7828,7 +7856,7 @@ var DefaultEmbedManyResult = class {
|
|
|
7828
7856
|
// src/generate-image/generate-image.ts
|
|
7829
7857
|
import { withUserAgentSuffix as withUserAgentSuffix5 } from "@ai-sdk/provider-utils";
|
|
7830
7858
|
async function generateImage({
|
|
7831
|
-
model,
|
|
7859
|
+
model: modelArg,
|
|
7832
7860
|
prompt,
|
|
7833
7861
|
n = 1,
|
|
7834
7862
|
maxImagesPerCall,
|
|
@@ -7841,13 +7869,7 @@ async function generateImage({
|
|
|
7841
7869
|
headers
|
|
7842
7870
|
}) {
|
|
7843
7871
|
var _a15, _b;
|
|
7844
|
-
|
|
7845
|
-
throw new UnsupportedModelVersionError({
|
|
7846
|
-
version: model.specificationVersion,
|
|
7847
|
-
provider: model.provider,
|
|
7848
|
-
modelId: model.modelId
|
|
7849
|
-
});
|
|
7850
|
-
}
|
|
7872
|
+
const model = resolveImageModel(modelArg);
|
|
7851
7873
|
const headersWithUserAgent = withUserAgentSuffix5(
|
|
7852
7874
|
headers != null ? headers : {},
|
|
7853
7875
|
`ai/${VERSION}`
|
|
@@ -7911,10 +7933,26 @@ async function generateImage({
|
|
|
7911
7933
|
}
|
|
7912
7934
|
if (result.providerMetadata) {
|
|
7913
7935
|
for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
|
|
7914
|
-
(
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7936
|
+
if (providerName === "gateway") {
|
|
7937
|
+
const currentEntry = providerMetadata[providerName];
|
|
7938
|
+
if (currentEntry != null && typeof currentEntry === "object") {
|
|
7939
|
+
providerMetadata[providerName] = {
|
|
7940
|
+
...currentEntry,
|
|
7941
|
+
...metadata
|
|
7942
|
+
};
|
|
7943
|
+
} else {
|
|
7944
|
+
providerMetadata[providerName] = metadata;
|
|
7945
|
+
}
|
|
7946
|
+
const imagesValue = providerMetadata[providerName].images;
|
|
7947
|
+
if (Array.isArray(imagesValue) && imagesValue.length === 0) {
|
|
7948
|
+
delete providerMetadata[providerName].images;
|
|
7949
|
+
}
|
|
7950
|
+
} else {
|
|
7951
|
+
(_b = providerMetadata[providerName]) != null ? _b : providerMetadata[providerName] = { images: [] };
|
|
7952
|
+
providerMetadata[providerName].images.push(
|
|
7953
|
+
...result.providerMetadata[providerName].images
|
|
7954
|
+
);
|
|
7955
|
+
}
|
|
7918
7956
|
}
|
|
7919
7957
|
}
|
|
7920
7958
|
responses.push(result.response);
|
|
@@ -9963,20 +10001,6 @@ var doWrap2 = ({
|
|
|
9963
10001
|
};
|
|
9964
10002
|
};
|
|
9965
10003
|
|
|
9966
|
-
// src/model/as-image-model-v3.ts
|
|
9967
|
-
function asImageModelV3(model) {
|
|
9968
|
-
if (model.specificationVersion === "v3") {
|
|
9969
|
-
return model;
|
|
9970
|
-
}
|
|
9971
|
-
return new Proxy(model, {
|
|
9972
|
-
get(target, prop) {
|
|
9973
|
-
if (prop === "specificationVersion")
|
|
9974
|
-
return "v3";
|
|
9975
|
-
return target[prop];
|
|
9976
|
-
}
|
|
9977
|
-
});
|
|
9978
|
-
}
|
|
9979
|
-
|
|
9980
10004
|
// src/model/as-provider-v3.ts
|
|
9981
10005
|
function asProviderV3(provider) {
|
|
9982
10006
|
if ("specificationVersion" in provider && provider.specificationVersion === "v3") {
|