Add triggers to various prompt queue stages
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 153
Description
### Feature Idea
I would love to see some additional hookable entry points during queue item processing by PromptServer / PromptQueue.
Namely (in other words my wish list):
**On Python side:**
1. In `PromptQueue.put` add hook like:
```
self.server.trigger_on_prompt_added(item)
```
2. In `PromptQueue.delete_queue_item` after item is successfully popped from queue - add hook like:
```
self.server.trigger_on_prompt_deleted(x)
```
3. In `PromptQueue.task_done` after item was popped from the queue and added to history - add hook like:
```
self.server.trigger_on_task_done((prompt, status_dict));
```
**On frontend side:**
1. In `api.queuePrompt` before prompt is submitted add event something like:
```
this.dispatchCustomEvent("beforePromptQueued", body);
```
or other hookable way to modify the **body** object.
### Existing Solutions
N/A
### Other
**Reasoning:**
I'm attempting to write a more robust prompt queue management extension (saving, restoring, reordering, grouping, modifying, archiving, logging etc) and I realised the current core treatment of the queue process on the backend does not provide much (or any) information about the queue item that is directly affected by a particular action like adding, deleting or completing.
On frontend there is no way to potentially modify the prompt (say I want to add some additional metadata to use later) before it's sent to the api endpoint.
This limits what can be done with the queue without cumbersome performance affecting workarounds or hijacking the queue completely and as a result potentially breaking compatibility with other extensions that might depend on data in it.
**Potential impact on currect core functionality**
Since these are just new hook entries without any additional data processing and without any flow changes, I believe the potential effect on current core functinality is between non-existent to miniscule, or in other words these are completely safe. The ball is in court of whoever gonna utilize these new hooks in the future (i.e. me).
I might try do the code and do a pull request if mega maintainers don's see any showstoppers for these suggestions.
Contributor guide
Assessment
This issue has not been assessed yet.