ai 4.0.13 → 4.0.14
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 +11 -0
- package/dist/index.d.mts +91 -2
- package/dist/index.d.ts +91 -2
- package/dist/index.js +68 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/test/dist/index.js +7 -8
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +7 -8
- package/test/dist/index.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -795,6 +795,45 @@ var DefaultEmbedManyResult = class {
|
|
795
795
|
}
|
796
796
|
};
|
797
797
|
|
798
|
+
// core/generate-image/generate-image.ts
|
799
|
+
import { convertBase64ToUint8Array } from "@ai-sdk/provider-utils";
|
800
|
+
async function generateImage({
|
801
|
+
model,
|
802
|
+
prompt,
|
803
|
+
n,
|
804
|
+
size,
|
805
|
+
providerOptions,
|
806
|
+
maxRetries: maxRetriesArg,
|
807
|
+
abortSignal,
|
808
|
+
headers
|
809
|
+
}) {
|
810
|
+
const { retry } = prepareRetries({ maxRetries: maxRetriesArg });
|
811
|
+
const { images } = await retry(
|
812
|
+
() => model.doGenerate({
|
813
|
+
prompt,
|
814
|
+
n: n != null ? n : 1,
|
815
|
+
abortSignal,
|
816
|
+
headers,
|
817
|
+
size,
|
818
|
+
providerOptions: providerOptions != null ? providerOptions : {}
|
819
|
+
})
|
820
|
+
);
|
821
|
+
return new DefaultGenerateImageResult({ base64Images: images });
|
822
|
+
}
|
823
|
+
var DefaultGenerateImageResult = class {
|
824
|
+
constructor(options) {
|
825
|
+
this.images = options.base64Images.map((base64) => ({
|
826
|
+
base64,
|
827
|
+
get uint8Array() {
|
828
|
+
return convertBase64ToUint8Array(this.base64);
|
829
|
+
}
|
830
|
+
}));
|
831
|
+
}
|
832
|
+
get image() {
|
833
|
+
return this.images[0];
|
834
|
+
}
|
835
|
+
};
|
836
|
+
|
798
837
|
// core/generate-object/generate-object.ts
|
799
838
|
import { createIdGenerator, safeParseJSON } from "@ai-sdk/provider-utils";
|
800
839
|
|
@@ -870,7 +909,7 @@ function detectImageMimeType(image) {
|
|
870
909
|
|
871
910
|
// core/prompt/data-content.ts
|
872
911
|
import {
|
873
|
-
convertBase64ToUint8Array,
|
912
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
874
913
|
convertUint8ArrayToBase64
|
875
914
|
} from "@ai-sdk/provider-utils";
|
876
915
|
|
@@ -926,7 +965,7 @@ function convertDataContentToUint8Array(content) {
|
|
926
965
|
}
|
927
966
|
if (typeof content === "string") {
|
928
967
|
try {
|
929
|
-
return
|
968
|
+
return convertBase64ToUint8Array2(content);
|
930
969
|
} catch (error) {
|
931
970
|
throw new InvalidDataContentError({
|
932
971
|
message: "Invalid data content. Content string is not a base64-encoded media.",
|
@@ -5511,6 +5550,7 @@ export {
|
|
5511
5550
|
embedMany,
|
5512
5551
|
experimental_createProviderRegistry,
|
5513
5552
|
experimental_customProvider,
|
5553
|
+
generateImage as experimental_generateImage,
|
5514
5554
|
experimental_wrapLanguageModel,
|
5515
5555
|
formatAssistantStreamPart2 as formatAssistantStreamPart,
|
5516
5556
|
formatDataStreamPart6 as formatDataStreamPart,
|