mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
558 stars 148 forks source link

Webhook feature and unique job_id #113

Closed bsormagec closed 8 months ago

bsormagec commented 8 months ago

Hey there,

I wanted to share some information with you regarding the API. I noticed that when using the async generation function, it requires you to check the system frequently after sending your job. This can be time-consuming and depends on several factors like performance, prompt complexity, and lora usage. Therefore, I implemented a webhook feature that will notify you when the task is completed.

Additionally, I noticed that there are sequential numbers in the async generation job_id that can create confusion. For example, if your system breaks down on job_id:13 and you have a record on your integrated software with job_id:13, and it's not finished yet, and you check the fooocus-api endpoint with that job_id, it might return you a different image. To solve this, I integrated uuid for job_id to make them unique. This way, if the system breaks down, you won't be able to retrieve the job_id.

I hope you find this information helpful. If you want to integrate all events, feel free to do so. I don't have enough time to do it myself.

Thank you.

bsormagec commented 8 months ago

I hope you merge it @konieshadow :)

konieshadow commented 8 months ago

Your consideration is indeed very valuable in a serious production environment, and you have given a very high quality solution. All I can say is it's fantastic. Regarding the job id issue, I actually had the same concerns at the beginning and never had time to fix it. Regarding webhooks, I think providing task completion hooks can satisfy most situations. If anyone else has a request, we can consider it again. BTW, I'll add some exception handlers for webhook sending.

konieshadow commented 8 months ago

@bsormagec Changed data format of webhook body to support multiple images generation in single job.

bsormagec commented 8 months ago

Your consideration is indeed very valuable in a serious production environment, and you have given a very high quality solution. All I can say is it's fantastic. Regarding the job id issue, I actually had the same concerns at the beginning and never had time to fix it. Regarding webhooks, I think providing task completion hooks can satisfy most situations. If anyone else has a request, we can consider it again. BTW, I'll add some exception handlers for webhook sending.

"I am thrilled to contribute further to your work. I am currently developing an app, and your API is an integral part of it. I want to express my appreciation for your work once again. I just wanted to suggest adding a feature for error reporting or something similar in the future." Always, 💪🏼 together