Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: client file upload #18

Merged
merged 10 commits into from
Nov 3, 2023
Merged

Conversation

drochetti
Copy link
Collaborator

@drochetti drochetti commented Oct 17, 2023

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:

fal.storage.upload(file: File): Promise<string>

2. Automatically upload

The main methods in the client, fal.run and fal.subscribe, will parse the input before it dispatches the request and upload any values that are either a File, a Blob or data: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:

const fileReference = /* get file from UI */

const result = await fal.subscribe("illusion-diffusion", {
  input: {
    image_url: fileReference // this becomes a string "https://..." before submitting
  }
});

@drochetti drochetti marked this pull request as draft October 17, 2023 06:48
@drochetti drochetti marked this pull request as ready for review October 24, 2023 14:46
libs/client/src/storage.ts Outdated Show resolved Hide resolved
@drochetti drochetti merged commit 78ffa58 into main Nov 3, 2023
1 check passed
@drochetti drochetti deleted the feature/file-upload-capabilities branch November 3, 2023 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants