Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Notes
This change introduces built-in file upload support to the JS client.
Problem
Often models will need file(s) as input. However, due to the long-running aspect of most ML-related operations, it's often handled completely async (i.e. through processing queues), which means files cannot be processed in real-time, and its reference cannot be kept in the queue, which is especially trick when the input is large (e.g. training data, videos).
Solution
The client will offer two features to address the problem:
1. An interface to fal's shared storage, which takes a file and returns a valid URL to it:
2. Automatically upload
The main methods in the client,
fal.run
andfal.subscribe
, will parse the input before it dispatches the request and upload any values that are either aFile
, aBlob
ordata:uri
string. This means that by default, users won't need to worry about what to do with arguments that are files and should be passed as URL. The client will use fal blob storage API to take care of that automatically behind the scenes.Some custom flows might need to handle upload themselves, in that case, users can either use
fal.storage.upload
themselves or their preferred method to store files and pass the URL string as input. Therefore, the auto-upload doesn't get in their wat, it only kicks in if it finds a file reference in the input, so: