vargai 0.4.0-alpha41 → 0.4.0-alpha42
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 +1 -1
- package/src/ai-sdk/providers/fal.ts +3 -24
package/package.json
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
type TranscriptionModelV3CallOptions,
|
|
12
12
|
} from "@ai-sdk/provider";
|
|
13
13
|
import { fal } from "@fal-ai/client";
|
|
14
|
-
import { uploadBuffer as uploadToR2 } from "../../providers/storage";
|
|
15
14
|
import { fileCache } from "../file-cache";
|
|
16
15
|
import type { VideoModelV3, VideoModelV3CallOptions } from "../video-model";
|
|
17
16
|
|
|
@@ -183,21 +182,6 @@ function detectImageType(bytes: Uint8Array): string | undefined {
|
|
|
183
182
|
return undefined;
|
|
184
183
|
}
|
|
185
184
|
|
|
186
|
-
function getExtFromMediaType(mediaType: string): string {
|
|
187
|
-
const map: Record<string, string> = {
|
|
188
|
-
"image/png": "png",
|
|
189
|
-
"image/jpeg": "jpg",
|
|
190
|
-
"image/gif": "gif",
|
|
191
|
-
"image/webp": "webp",
|
|
192
|
-
"video/mp4": "mp4",
|
|
193
|
-
"video/webm": "webm",
|
|
194
|
-
"audio/mpeg": "mp3",
|
|
195
|
-
"audio/wav": "wav",
|
|
196
|
-
"audio/ogg": "ogg",
|
|
197
|
-
};
|
|
198
|
-
return map[mediaType] ?? "bin";
|
|
199
|
-
}
|
|
200
|
-
|
|
201
185
|
async function fileToUrl(file: ImageModelV3File): Promise<string> {
|
|
202
186
|
if (file.type === "url") return file.url;
|
|
203
187
|
const data = file.data;
|
|
@@ -205,18 +189,13 @@ async function fileToUrl(file: ImageModelV3File): Promise<string> {
|
|
|
205
189
|
typeof data === "string"
|
|
206
190
|
? Uint8Array.from(atob(data), (c) => c.charCodeAt(0))
|
|
207
191
|
: data;
|
|
192
|
+
// Use mediaType from file if available, otherwise detect from bytes or default to png
|
|
208
193
|
const mediaType = file.mediaType ?? detectImageType(bytes) ?? "image/png";
|
|
209
|
-
|
|
210
|
-
const hash = Bun.hash(bytes).toString(16);
|
|
211
|
-
const key = `fal-uploads/${hash}.${ext}`;
|
|
212
|
-
return uploadToR2(bytes, key, mediaType);
|
|
194
|
+
return fal.storage.upload(new Blob([bytes], { type: mediaType }));
|
|
213
195
|
}
|
|
214
196
|
|
|
215
197
|
async function uploadBuffer(buffer: ArrayBuffer): Promise<string> {
|
|
216
|
-
|
|
217
|
-
const hash = Bun.hash(bytes).toString(16);
|
|
218
|
-
const key = `fal-uploads/${hash}.bin`;
|
|
219
|
-
return uploadToR2(bytes, key);
|
|
198
|
+
return fal.storage.upload(new Blob([buffer]));
|
|
220
199
|
}
|
|
221
200
|
|
|
222
201
|
export function computePendingKey(
|