webui: support cancelation - #182
Conversation
lstein
left a comment
There was a problem hiding this comment.
Good addition to the previus PR. Hopefully we can get both in soon. There are source conflicts, but they don't look too daunting.
|
I tested this PR. It's working fine. I can approve it if you want @lstein ... Both the streaming and the cancelation are working as expected. |
|
|
@bakkot , we've run into the CRLF issue again. Could you fix the line endings and rebase? |
Yeah. I am doing formal ones. But on this one I held off because two PR's about the similar topic were open and the other one seemed to be in progress. |
|
Rebased. |
|
@blessedcoolant indicated review approval in comments, so going ahead with merge. |
webui: support cancelation
This is on top of #181, which is itself on top of #180. (Github does not have a good way of staging multiple PRs.) Changes in this PR are just the "support cancelation" commit. This PR works even without #181, but it's a lot more useful with it.
This adds a button next to the progress bar which allows you to cancel the in-progress generation - e.g. if you asked for 5 images and then discovered after the first 2 that you want to tweak the prompt, or if the partial rendering from #180 was enough to know it wasn't what you were looking for. It accomplishes this by throwing an exception in the per-step callback and catching it outside the call to
prompt2image, which, while a bit gross, is fundamentally the same thing as hitting ctrl-c and catching the KeyboardInterrupt. That's what the REPL does, so it should be ok.Cancelation does need to wait for the current step to finish rather than actually being instant, but it's only a second or two of delay, and I didn't really want to get into dealing with actual interrupts or deeper magic.
screenshot of button