enh: abililty to stop merge response

This commit is contained in:
Timothy Jaeryang Baek 2025-08-05 22:25:51 +04:00
parent 8b46a9010e
commit d0657054a5
3 changed files with 18 additions and 3 deletions

View file

@ -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) => {

View file

@ -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

View file

@ -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