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

Support for async requests or webhooks #348

Open
brian316 opened this issue Oct 29, 2024 · 2 comments
Open

Support for async requests or webhooks #348

brian316 opened this issue Oct 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@brian316
Copy link

brian316 commented Oct 29, 2024


🚀 Feature

Is there currently a way to run inference and get the result by polling or a webhook callback?

Motivation

If an inference takes a long time to run lets say 30 min you dont want the connection to drop because you will have to rerun the inference especially on a shaky connection.

Pitch

A webhook callback or polling method can let us run inference as a background task based off a uuid or something the user specifies so that they can come back at a later time for the result. can also help integrations so the inference is not a blocking request.

Alternatives

Cog from replicate implements a webhook

Additional context

@brian316 brian316 added the enhancement New feature or request label Oct 29, 2024
@aniketmaurya
Copy link
Collaborator

@brian316 this is a great feature! You can already do this with LitServe 😄

Here are the steps:

  1. Send the webhook endpoint in request body
  2. Use callback and define hooks at on_after_decode_request , on_after_predict and on_after_encode_response.
  3. Send the current status of request/response in each hooks/stage.

@brian316
Copy link
Author

I've looked at the documentation and saw those handy Hooks, but wouldn't the the initial api request wait until the server returns something? I was thinking of returning something immediately like an id the user can poll for the polling method or for the web hook method return a success message. while still running the background task. I guess something that could potentially work is returning immediately in the predict function and run some thread in the background but that seems hacky to get it to work. having async task is important for my type of tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants