mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
enh: abililty to stop merge response
This commit is contained in:
parent
8b46a9010e
commit
d0657054a5
3 changed files with 18 additions and 3 deletions
|
|
@ -128,6 +128,9 @@
|
|||
|
||||
let showCommands = false;
|
||||
|
||||
let generating = false;
|
||||
let generationController = null;
|
||||
|
||||
let chat = null;
|
||||
let tags = [];
|
||||
|
||||
|
|
@ -1857,6 +1860,12 @@
|
|||
scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
if (generating) {
|
||||
generating = false;
|
||||
generationController?.abort();
|
||||
generationController = null;
|
||||
}
|
||||
};
|
||||
|
||||
const submitMessage = async (parentId, prompt) => {
|
||||
|
|
@ -1947,6 +1956,7 @@
|
|||
history.messages[messageId] = message;
|
||||
|
||||
try {
|
||||
generating = true;
|
||||
const [res, controller] = await generateMoACompletion(
|
||||
localStorage.token,
|
||||
message.model,
|
||||
|
|
@ -1954,11 +1964,14 @@
|
|||
responses
|
||||
);
|
||||
|
||||
if (res && res.ok && res.body) {
|
||||
if (res && res.ok && res.body && generating) {
|
||||
generationController = controller;
|
||||
const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks);
|
||||
for await (const update of textStream) {
|
||||
const { value, done, sources, error, usage } = update;
|
||||
if (error || done) {
|
||||
generating = false;
|
||||
generationController = null;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2190,6 +2203,7 @@
|
|||
transparentBackground={$settings?.backgroundImageUrl ??
|
||||
$config?.license_metadata?.background_image_url ??
|
||||
false}
|
||||
{generating}
|
||||
{stopResponse}
|
||||
{createMessagePair}
|
||||
onChange={(data) => {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@
|
|||
export let stopResponse: Function;
|
||||
|
||||
export let autoScroll = false;
|
||||
export let generating = false;
|
||||
|
||||
export let atSelectedModel: Model | undefined = undefined;
|
||||
export let selectedModels: [''];
|
||||
|
|
@ -1820,7 +1821,7 @@
|
|||
</Tooltip>
|
||||
{/if}
|
||||
|
||||
{#if (taskIds && taskIds.length > 0) || (history.currentId && history.messages[history.currentId]?.done != true)}
|
||||
{#if (taskIds && taskIds.length > 0) || (history.currentId && history.messages[history.currentId]?.done != true) || generating}
|
||||
<div class=" flex items-center">
|
||||
<Tooltip content={$i18n.t('Stop')}>
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<div class={outerClassName}>
|
||||
<label class="sr-only" for="password-input">{placeholder || $i18n.t('Password')}</label>
|
||||
<input
|
||||
class={`${inputClassName} ${show ? '' : 'password'} ${($settings?.highContrastMode ?? false) ? 'placeholder:text-gray-700 dark:placeholder:text-gray-100' : ' outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700'}`}
|
||||
class={`${inputClassName} ${show ? '' : 'password'} ${($settings?.highContrastMode ?? false) ? 'placeholder:text-gray-700 dark:placeholder:text-gray-100' : ' outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-600'}`}
|
||||
{placeholder}
|
||||
id="password-input"
|
||||
bind:value
|
||||
|
|
|
|||
Loading…
Reference in a new issue