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/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 convertBase64ToUint8Array(content);
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,