mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
8febc54a88
commit
09b5c1b4dc
2 changed files with 39 additions and 22 deletions
|
|
@ -120,6 +120,8 @@
|
||||||
let enhancing = false;
|
let enhancing = false;
|
||||||
let streaming = false;
|
let streaming = false;
|
||||||
|
|
||||||
|
let stopResponseFlag = false;
|
||||||
|
|
||||||
let inputElement = null;
|
let inputElement = null;
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
|
|
@ -214,6 +216,11 @@
|
||||||
versionIdx = null;
|
versionIdx = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stopResponseHandler = async () => {
|
||||||
|
stopResponseFlag = true;
|
||||||
|
console.log('stopResponse', stopResponseFlag);
|
||||||
|
};
|
||||||
|
|
||||||
function setContentByVersion(versionIdx) {
|
function setContentByVersion(versionIdx) {
|
||||||
if (!note.data.versions?.length) return;
|
if (!note.data.versions?.length) return;
|
||||||
let idx = versionIdx;
|
let idx = versionIdx;
|
||||||
|
|
@ -578,7 +585,13 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const { value, done } = await reader.read();
|
const { value, done } = await reader.read();
|
||||||
if (done) {
|
if (done || stopResponseFlag) {
|
||||||
|
if (stopResponseFlag) {
|
||||||
|
controller.abort('User: Stop Response');
|
||||||
|
}
|
||||||
|
|
||||||
|
enhancing = false;
|
||||||
|
streaming = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1019,22 +1032,28 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
</Tooltip> -->
|
</Tooltip> -->
|
||||||
|
|
||||||
<Tooltip content={$i18n.t('Enhance')} placement="top">
|
<Tooltip content={$i18n.t('Enhance')} placement="top">
|
||||||
<button
|
{#if enhancing}
|
||||||
class="{enhancing
|
<button
|
||||||
? 'p-2'
|
class="p-2 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
|
||||||
: 'p-2.5'} flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
|
on:click={() => {
|
||||||
on:click={() => {
|
stopResponseHandler();
|
||||||
enhanceNoteHandler();
|
}}
|
||||||
}}
|
type="button"
|
||||||
disabled={enhancing}
|
>
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
{#if enhancing}
|
|
||||||
<Spinner className="size-5" />
|
<Spinner className="size-5" />
|
||||||
{:else}
|
</button>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
class="p-2.5 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
|
||||||
|
on:click={() => {
|
||||||
|
enhanceNoteHandler();
|
||||||
|
}}
|
||||||
|
disabled={enhancing}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
<SparklesSolid />
|
<SparklesSolid />
|
||||||
{/if}
|
</button>
|
||||||
</button>
|
{/if}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -1050,8 +1069,10 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
bind:note
|
bind:note
|
||||||
bind:enhancing
|
bind:enhancing
|
||||||
bind:streaming
|
bind:streaming
|
||||||
|
bind:stopResponseFlag
|
||||||
{files}
|
{files}
|
||||||
onInsert={insertHandler}
|
onInsert={insertHandler}
|
||||||
|
onStop={stopResponseHandler}
|
||||||
/>
|
/>
|
||||||
{:else if selectedPanel === 'settings'}
|
{:else if selectedPanel === 'settings'}
|
||||||
<Settings bind:show={showPanel} bind:selectedModelId />
|
<Settings bind:show={showPanel} bind:selectedModelId />
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
export let enhancing = false;
|
export let enhancing = false;
|
||||||
export let streaming = false;
|
export let streaming = false;
|
||||||
|
export let stopResponseFlag = false;
|
||||||
|
|
||||||
export let note = null;
|
export let note = null;
|
||||||
|
|
||||||
|
|
@ -38,12 +39,12 @@
|
||||||
export let messages = [];
|
export let messages = [];
|
||||||
|
|
||||||
export let onInsert = (content) => {};
|
export let onInsert = (content) => {};
|
||||||
|
export let onStop = () => {};
|
||||||
export let scrollToBottomHandler = () => {};
|
export let scrollToBottomHandler = () => {};
|
||||||
|
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
let stopResponseFlag = false;
|
|
||||||
|
|
||||||
let messagesContainerElement: HTMLDivElement;
|
let messagesContainerElement: HTMLDivElement;
|
||||||
|
|
||||||
|
|
@ -88,11 +89,6 @@ Based on the user's instruction, update and enhance the existing notes by incorp
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const stopHandler = () => {
|
|
||||||
stopResponseFlag = true;
|
|
||||||
console.log('stopResponse');
|
|
||||||
};
|
|
||||||
|
|
||||||
const chatCompletionHandler = async () => {
|
const chatCompletionHandler = async () => {
|
||||||
if (selectedModelId === '') {
|
if (selectedModelId === '') {
|
||||||
toast.error($i18n.t('Please select a model.'));
|
toast.error($i18n.t('Please select a model.'));
|
||||||
|
|
@ -341,7 +337,7 @@ Based on the user's instruction, update and enhance the existing notes by incorp
|
||||||
acceptFiles={false}
|
acceptFiles={false}
|
||||||
inputLoading={loading}
|
inputLoading={loading}
|
||||||
onSubmit={submitHandler}
|
onSubmit={submitHandler}
|
||||||
onStop={stopHandler}
|
{onStop}
|
||||||
>
|
>
|
||||||
<div slot="menu" class="flex items-center justify-between gap-2 w-full pr-2">
|
<div slot="menu" class="flex items-center justify-between gap-2 w-full pr-2">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue