forked from open-webui/open-webui
feat: reading indicator
This commit is contained in:
parent
6271ee64ab
commit
9083ee8a5d
3 changed files with 58 additions and 1 deletions
|
@ -10,11 +10,13 @@
|
||||||
import UserMessage from './Messages/UserMessage.svelte';
|
import UserMessage from './Messages/UserMessage.svelte';
|
||||||
import ResponseMessage from './Messages/ResponseMessage.svelte';
|
import ResponseMessage from './Messages/ResponseMessage.svelte';
|
||||||
import Placeholder from './Messages/Placeholder.svelte';
|
import Placeholder from './Messages/Placeholder.svelte';
|
||||||
|
import Spinner from '../common/Spinner.svelte';
|
||||||
|
|
||||||
export let chatId = '';
|
export let chatId = '';
|
||||||
export let sendPrompt: Function;
|
export let sendPrompt: Function;
|
||||||
export let regenerateResponse: Function;
|
export let regenerateResponse: Function;
|
||||||
|
|
||||||
|
export let processing = '';
|
||||||
export let bottomPadding = false;
|
export let bottomPadding = false;
|
||||||
export let autoScroll;
|
export let autoScroll;
|
||||||
export let selectedModels;
|
export let selectedModels;
|
||||||
|
@ -218,7 +220,7 @@
|
||||||
{#key chatId}
|
{#key chatId}
|
||||||
{#each messages as message, messageIdx}
|
{#each messages as message, messageIdx}
|
||||||
<div class=" w-full">
|
<div class=" w-full">
|
||||||
<div class="flex justify-between px-5 mb-3 max-w-3xl mx-auto rounded-lg group">
|
<div class="flex flex-col justify-between px-5 mb-3 max-w-3xl mx-auto rounded-lg group">
|
||||||
{#if message.role === 'user'}
|
{#if message.role === 'user'}
|
||||||
<UserMessage
|
<UserMessage
|
||||||
user={$user}
|
user={$user}
|
||||||
|
@ -233,6 +235,52 @@
|
||||||
{showNextMessage}
|
{showNextMessage}
|
||||||
{copyToClipboard}
|
{copyToClipboard}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{#if processing !== ''}
|
||||||
|
<div class="flex my-2.5 ml-12 items-center w-fit space-x-2.5">
|
||||||
|
<div class=" dark:text-blue-100">
|
||||||
|
<svg
|
||||||
|
class=" w-4 h-4 translate-y-[0.5px]"
|
||||||
|
fill="currentColor"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
><style>
|
||||||
|
.spinner_qM83 {
|
||||||
|
animation: spinner_8HQG 1.05s infinite;
|
||||||
|
}
|
||||||
|
.spinner_oXPr {
|
||||||
|
animation-delay: 0.1s;
|
||||||
|
}
|
||||||
|
.spinner_ZTLf {
|
||||||
|
animation-delay: 0.2s;
|
||||||
|
}
|
||||||
|
@keyframes spinner_8HQG {
|
||||||
|
0%,
|
||||||
|
57.14% {
|
||||||
|
animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1);
|
||||||
|
transform: translate(0);
|
||||||
|
}
|
||||||
|
28.57% {
|
||||||
|
animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33);
|
||||||
|
transform: translateY(-6px);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translate(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style><circle class="spinner_qM83" cx="4" cy="12" r="2.5" /><circle
|
||||||
|
class="spinner_qM83 spinner_oXPr"
|
||||||
|
cx="12"
|
||||||
|
cy="12"
|
||||||
|
r="2.5"
|
||||||
|
/><circle class="spinner_qM83 spinner_ZTLf" cx="20" cy="12" r="2.5" /></svg
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class=" text-sm font-medium">
|
||||||
|
{processing}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<ResponseMessage
|
<ResponseMessage
|
||||||
{message}
|
{message}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
let stopResponseFlag = false;
|
let stopResponseFlag = false;
|
||||||
let autoScroll = true;
|
let autoScroll = true;
|
||||||
|
let processing = '';
|
||||||
|
|
||||||
let selectedModels = [''];
|
let selectedModels = [''];
|
||||||
|
|
||||||
|
@ -192,6 +193,7 @@
|
||||||
|
|
||||||
console.log(docs);
|
console.log(docs);
|
||||||
if (docs.length > 0) {
|
if (docs.length > 0) {
|
||||||
|
processing = 'Reading';
|
||||||
const query = history.messages[parentId].content;
|
const query = history.messages[parentId].content;
|
||||||
|
|
||||||
let relevantContexts = await Promise.all(
|
let relevantContexts = await Promise.all(
|
||||||
|
@ -215,6 +217,7 @@
|
||||||
history.messages[parentId].raContent = RAGTemplate(contextString, query);
|
history.messages[parentId].raContent = RAGTemplate(contextString, query);
|
||||||
history.messages[parentId].contexts = relevantContexts;
|
history.messages[parentId].contexts = relevantContexts;
|
||||||
await tick();
|
await tick();
|
||||||
|
processing = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
@ -660,6 +663,7 @@
|
||||||
chatId={$chatId}
|
chatId={$chatId}
|
||||||
{selectedModels}
|
{selectedModels}
|
||||||
{selectedModelfiles}
|
{selectedModelfiles}
|
||||||
|
{processing}
|
||||||
bind:history
|
bind:history
|
||||||
bind:messages
|
bind:messages
|
||||||
bind:autoScroll
|
bind:autoScroll
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
import { RAGTemplate } from '$lib/utils/rag';
|
import { RAGTemplate } from '$lib/utils/rag';
|
||||||
|
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
|
|
||||||
let stopResponseFlag = false;
|
let stopResponseFlag = false;
|
||||||
let autoScroll = true;
|
let autoScroll = true;
|
||||||
|
let processing = '';
|
||||||
|
|
||||||
// let chatId = $page.params.id;
|
// let chatId = $page.params.id;
|
||||||
let selectedModels = [''];
|
let selectedModels = [''];
|
||||||
|
@ -210,6 +212,7 @@
|
||||||
|
|
||||||
console.log(docs);
|
console.log(docs);
|
||||||
if (docs.length > 0) {
|
if (docs.length > 0) {
|
||||||
|
processing = 'Reading';
|
||||||
const query = history.messages[parentId].content;
|
const query = history.messages[parentId].content;
|
||||||
|
|
||||||
let relevantContexts = await Promise.all(
|
let relevantContexts = await Promise.all(
|
||||||
|
@ -233,6 +236,7 @@
|
||||||
history.messages[parentId].raContent = RAGTemplate(contextString, query);
|
history.messages[parentId].raContent = RAGTemplate(contextString, query);
|
||||||
history.messages[parentId].contexts = relevantContexts;
|
history.messages[parentId].contexts = relevantContexts;
|
||||||
await tick();
|
await tick();
|
||||||
|
processing = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
@ -685,6 +689,7 @@
|
||||||
chatId={$chatId}
|
chatId={$chatId}
|
||||||
{selectedModels}
|
{selectedModels}
|
||||||
{selectedModelfiles}
|
{selectedModelfiles}
|
||||||
|
{processing}
|
||||||
bind:history
|
bind:history
|
||||||
bind:messages
|
bind:messages
|
||||||
bind:autoScroll
|
bind:autoScroll
|
||||||
|
|
Loading…
Reference in a new issue