mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac
This commit is contained in:
parent
3c80219808
commit
baa1a44397
2 changed files with 22 additions and 14 deletions
|
|
@ -123,7 +123,7 @@
|
||||||
let dragged = false;
|
let dragged = false;
|
||||||
let loading = false;
|
let loading = false;
|
||||||
|
|
||||||
let enhancing = false;
|
let editing = false;
|
||||||
let streaming = false;
|
let streaming = false;
|
||||||
|
|
||||||
let stopResponseFlag = false;
|
let stopResponseFlag = false;
|
||||||
|
|
@ -190,6 +190,11 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onEdited = async () => {
|
||||||
|
if (!editor) return;
|
||||||
|
editor.commands.setContent(note.data.content.html);
|
||||||
|
};
|
||||||
|
|
||||||
async function enhanceNoteHandler() {
|
async function enhanceNoteHandler() {
|
||||||
if (selectedModelId === '') {
|
if (selectedModelId === '') {
|
||||||
toast.error($i18n.t('Please select a model.'));
|
toast.error($i18n.t('Please select a model.'));
|
||||||
|
|
@ -205,12 +210,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
enhancing = true;
|
editing = true;
|
||||||
|
|
||||||
insertNoteVersion(note);
|
|
||||||
await enhanceCompletionHandler(model);
|
await enhanceCompletionHandler(model);
|
||||||
|
editing = false;
|
||||||
|
|
||||||
enhancing = false;
|
onEdited();
|
||||||
versionIdx = null;
|
versionIdx = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -591,7 +595,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
controller.abort('User: Stop Response');
|
controller.abort('User: Stop Response');
|
||||||
}
|
}
|
||||||
|
|
||||||
enhancing = false;
|
editing = false;
|
||||||
streaming = false;
|
streaming = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -930,7 +934,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
class=" flex-1 w-full h-full overflow-auto px-3.5 pb-20 relative pt-2.5"
|
class=" flex-1 w-full h-full overflow-auto px-3.5 pb-20 relative pt-2.5"
|
||||||
id="note-content-container"
|
id="note-content-container"
|
||||||
>
|
>
|
||||||
{#if enhancing}
|
{#if editing}
|
||||||
<div
|
<div
|
||||||
class="w-full h-full fixed top-0 left-0 {streaming
|
class="w-full h-full fixed top-0 left-0 {streaming
|
||||||
? ''
|
? ''
|
||||||
|
|
@ -985,7 +989,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
user={$user}
|
user={$user}
|
||||||
link={true}
|
link={true}
|
||||||
placeholder={$i18n.t('Write something...')}
|
placeholder={$i18n.t('Write something...')}
|
||||||
editable={versionIdx === null && !enhancing}
|
editable={versionIdx === null && !editing}
|
||||||
onChange={(content) => {
|
onChange={(content) => {
|
||||||
note.data.content.html = content.html;
|
note.data.content.html = content.html;
|
||||||
note.data.content.md = content.md;
|
note.data.content.md = content.md;
|
||||||
|
|
@ -1100,7 +1104,7 @@ 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">
|
||||||
{#if enhancing}
|
{#if editing}
|
||||||
<button
|
<button
|
||||||
class="p-2 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
|
class="p-2 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
@ -1116,7 +1120,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
enhanceNoteHandler();
|
enhanceNoteHandler();
|
||||||
}}
|
}}
|
||||||
disabled={enhancing}
|
disabled={editing}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<SparklesSolid />
|
<SparklesSolid />
|
||||||
|
|
@ -1135,12 +1139,13 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
bind:selectedModelId
|
bind:selectedModelId
|
||||||
bind:messages
|
bind:messages
|
||||||
bind:note
|
bind:note
|
||||||
bind:enhancing
|
bind:editing
|
||||||
bind:streaming
|
bind:streaming
|
||||||
bind:stopResponseFlag
|
bind:stopResponseFlag
|
||||||
{files}
|
{files}
|
||||||
onInsert={insertHandler}
|
onInsert={insertHandler}
|
||||||
onStop={stopResponseHandler}
|
onStop={stopResponseHandler}
|
||||||
|
{onEdited}
|
||||||
insertNoteHandler={() => {
|
insertNoteHandler={() => {
|
||||||
insertNoteVersion(note);
|
insertNoteVersion(note);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
export let enhancing = false;
|
export let editing = false;
|
||||||
export let streaming = false;
|
export let streaming = false;
|
||||||
export let stopResponseFlag = false;
|
export let stopResponseFlag = false;
|
||||||
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
|
|
||||||
export let onInsert = (content) => {};
|
export let onInsert = (content) => {};
|
||||||
export let onStop = () => {};
|
export let onStop = () => {};
|
||||||
|
export let onEdited = () => {};
|
||||||
|
|
||||||
export let insertNoteHandler = () => {};
|
export let insertNoteHandler = () => {};
|
||||||
export let scrollToBottomHandler = () => {};
|
export let scrollToBottomHandler = () => {};
|
||||||
|
|
@ -205,9 +206,11 @@ Based on the user's instruction, update and enhance the existing notes by incorp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editorEnabled) {
|
if (editorEnabled) {
|
||||||
enhancing = false;
|
editing = false;
|
||||||
streaming = false;
|
streaming = false;
|
||||||
|
onEdited();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +236,7 @@ Based on the user's instruction, update and enhance the existing notes by incorp
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (editorEnabled) {
|
if (editorEnabled) {
|
||||||
enhancing = true;
|
editing = true;
|
||||||
streaming = true;
|
streaming = true;
|
||||||
|
|
||||||
enhancedContent.md += deltaContent;
|
enhancedContent.md += deltaContent;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue