vargai 0.4.0-alpha42 → 0.4.0-alpha44

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/package.json CHANGED
@@ -40,10 +40,9 @@
40
40
  "dependencies": {
41
41
  "@ai-sdk/fal": "^1.0.23",
42
42
  "@ai-sdk/fireworks": "^2.0.16",
43
- "@ai-sdk/groq": "^3.0.12",
44
43
  "@ai-sdk/google": "^3.0.13",
44
+ "@ai-sdk/groq": "^3.0.12",
45
45
  "@ai-sdk/openai": "^3.0.9",
46
- "@google/genai": "^1.0.0",
47
46
  "@ai-sdk/provider": "^3.0.2",
48
47
  "@ai-sdk/provider-utils": "^4.0.4",
49
48
  "@ai-sdk/replicate": "^2.0.5",
@@ -51,6 +50,7 @@
51
50
  "@aws-sdk/s3-request-presigner": "^3.937.0",
52
51
  "@elevenlabs/elevenlabs-js": "^2.28.0",
53
52
  "@fal-ai/client": "^1.7.2",
53
+ "@google/genai": "^1.0.0",
54
54
  "@higgsfield/client": "^0.1.2",
55
55
  "@inkjs/ui": "^2.0.0",
56
56
  "@remotion/cli": "^4.0.377",
@@ -61,6 +61,7 @@
61
61
  "fluent-ffmpeg": "^2.1.3",
62
62
  "groq-sdk": "^0.36.0",
63
63
  "ink": "^6.5.1",
64
+ "p-map": "^7.0.4",
64
65
  "react": "^19.2.0",
65
66
  "react-dom": "^19.2.0",
66
67
  "remotion": "^4.0.377",
@@ -68,7 +69,7 @@
68
69
  "sharp": "^0.34.5",
69
70
  "zod": "^4.2.1"
70
71
  },
71
- "version": "0.4.0-alpha42",
72
+ "version": "0.4.0-alpha44",
72
73
  "exports": {
73
74
  ".": "./src/index.ts",
74
75
  "./ai": "./src/ai-sdk/index.ts",
@@ -11,6 +11,7 @@ import {
11
11
  type TranscriptionModelV3CallOptions,
12
12
  } from "@ai-sdk/provider";
13
13
  import { fal } from "@fal-ai/client";
14
+ import pMap from "p-map";
14
15
  import { fileCache } from "../file-cache";
15
16
  import type { VideoModelV3, VideoModelV3CallOptions } from "../video-model";
16
17
 
@@ -182,6 +183,8 @@ function detectImageType(bytes: Uint8Array): string | undefined {
182
183
  return undefined;
183
184
  }
184
185
 
186
+ const uploadCache = fileCache({ dir: ".cache/fal-uploads" });
187
+
185
188
  async function fileToUrl(file: ImageModelV3File): Promise<string> {
186
189
  if (file.type === "url") return file.url;
187
190
  const data = file.data;
@@ -189,9 +192,15 @@ async function fileToUrl(file: ImageModelV3File): Promise<string> {
189
192
  typeof data === "string"
190
193
  ? Uint8Array.from(atob(data), (c) => c.charCodeAt(0))
191
194
  : data;
192
- // Use mediaType from file if available, otherwise detect from bytes or default to png
195
+
196
+ const hash = Bun.hash(bytes).toString(16);
197
+ const cached = (await uploadCache.get(hash)) as string | undefined;
198
+ if (cached) return cached;
199
+
193
200
  const mediaType = file.mediaType ?? detectImageType(bytes) ?? "image/png";
194
- return fal.storage.upload(new Blob([bytes], { type: mediaType }));
201
+ const url = await fal.storage.upload(new Blob([bytes], { type: mediaType }));
202
+ await uploadCache.set(hash, url, 7 * 24 * 60 * 60 * 1000);
203
+ return url;
195
204
  }
196
205
 
197
206
  async function uploadBuffer(buffer: ArrayBuffer): Promise<string> {
@@ -748,7 +757,7 @@ class FalImageModel implements ImageModelV3 {
748
757
  modelId: this.modelId,
749
758
  fileHashes,
750
759
  });
751
- input.image_urls = await Promise.all(files.map((f) => fileToUrl(f)));
760
+ input.image_urls = await pMap(files, fileToUrl, { concurrency: 2 });
752
761
  }
753
762
 
754
763
  if (isQwenAngles && !input.image_urls) {