Clean up Generate(), part 2 (#1578)

* Move StreamingProcessor constructor to the top

Typical code style is to declare the constructor at the top of the class
definition.

* Remove removePrefix

cleanupMessage does this already.

* Make message_already_generated local

We can pass it into StreamingProcessor so it doesn't have to be a global
variable.

* Consolidate setting isStopped and abort signal

Various places were doing some combination of setting isStopped, calling
abort on the streaming processor's abort controller, and calling
onStopStreaming. Let's consolidate all that functionality into
onStopStreaming/onErrorStreaming.

* More cleanly separate streaming/nonstreaming paths

* Replace promise with async function w/ handlers

By using onSuccess and onError as promise handlers, we can use normal
control flow and don't need to remember to use try/catch blocks or call
onSuccess every time.

* Remove runGenerate

Placing the rest of the code in a separate function doesn't really do
anything for its structure.

* Move StreamingProcessor() into streaming code path

* Fix return from circuit breaker

* Fix non-streaming chat completion request

* Fix Horde generation and quiet unblocking

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
valadaptive 2023-12-21 13:20:28 -05:00 committed by GitHub
parent bddccd0356
commit 8fb26284e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 641 additions and 654 deletions

File diff suppressed because it is too large Load Diff

View File

@ -637,6 +637,9 @@ hr {
order: 2;
padding-right: 2px;
place-self: center;
cursor: pointer;
transition: 0.3s;
opacity: 0.7;
}
#options_button {