|
@@ -15,9 +15,6 @@
|
|
import {
|
|
import {
|
|
copyToClipboard as _copyToClipboard,
|
|
copyToClipboard as _copyToClipboard,
|
|
approximateToHumanReadable,
|
|
approximateToHumanReadable,
|
|
- extractParagraphsForAudio,
|
|
|
|
- extractSentencesForAudio,
|
|
|
|
- cleanText,
|
|
|
|
getMessageContentParts,
|
|
getMessageContentParts,
|
|
sanitizeResponseContent,
|
|
sanitizeResponseContent,
|
|
createMessagesList
|
|
createMessagesList
|
|
@@ -33,7 +30,6 @@
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
|
import WebSearchResults from './ResponseMessage/WebSearchResults.svelte';
|
|
import WebSearchResults from './ResponseMessage/WebSearchResults.svelte';
|
|
import Sparkles from '$lib/components/icons/Sparkles.svelte';
|
|
import Sparkles from '$lib/components/icons/Sparkles.svelte';
|
|
- import Markdown from './Markdown.svelte';
|
|
|
|
import Error from './Error.svelte';
|
|
import Error from './Error.svelte';
|
|
import Citations from './Citations.svelte';
|
|
import Citations from './Citations.svelte';
|
|
import CodeExecutions from './CodeExecutions.svelte';
|
|
import CodeExecutions from './CodeExecutions.svelte';
|
|
@@ -112,9 +108,13 @@
|
|
export let showPreviousMessage: Function;
|
|
export let showPreviousMessage: Function;
|
|
export let showNextMessage: Function;
|
|
export let showNextMessage: Function;
|
|
|
|
|
|
|
|
+ export let updateChat: Function;
|
|
export let editMessage: Function;
|
|
export let editMessage: Function;
|
|
|
|
+ export let saveMessage: Function;
|
|
export let rateMessage: Function;
|
|
export let rateMessage: Function;
|
|
|
|
+ export let actionMessage: Function;
|
|
|
|
|
|
|
|
+ export let submitMessage: Function;
|
|
export let continueResponse: Function;
|
|
export let continueResponse: Function;
|
|
export let regenerateResponse: Function;
|
|
export let regenerateResponse: Function;
|
|
|
|
|
|
@@ -329,7 +329,10 @@
|
|
url: `${image.url}`
|
|
url: `${image.url}`
|
|
}));
|
|
}));
|
|
|
|
|
|
- dispatch('save', { ...message, files: files });
|
|
|
|
|
|
+ saveMessage(message.id, {
|
|
|
|
+ ...message,
|
|
|
|
+ files: files
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
generatingImage = false;
|
|
generatingImage = false;
|
|
@@ -422,7 +425,7 @@
|
|
}
|
|
}
|
|
|
|
|
|
console.log(updatedMessage);
|
|
console.log(updatedMessage);
|
|
- dispatch('save', updatedMessage);
|
|
|
|
|
|
+ saveMessage(message.id, updatedMessage);
|
|
|
|
|
|
await tick();
|
|
await tick();
|
|
|
|
|
|
@@ -443,7 +446,7 @@
|
|
updatedMessage.annotation.tags = tags;
|
|
updatedMessage.annotation.tags = tags;
|
|
feedbackItem.data.tags = tags;
|
|
feedbackItem.data.tags = tags;
|
|
|
|
|
|
- dispatch('save', updatedMessage);
|
|
|
|
|
|
+ saveMessage(message.id, updatedMessage);
|
|
await updateFeedbackById(
|
|
await updateFeedbackById(
|
|
localStorage.token,
|
|
localStorage.token,
|
|
updatedMessage.feedbackId,
|
|
updatedMessage.feedbackId,
|
|
@@ -631,22 +634,19 @@
|
|
message.id
|
|
message.id
|
|
].content.replace(raw, raw.replace(oldContent, newContent));
|
|
].content.replace(raw, raw.replace(oldContent, newContent));
|
|
|
|
|
|
- dispatch('update');
|
|
|
|
|
|
+ updateChat();
|
|
}}
|
|
}}
|
|
on:select={(e) => {
|
|
on:select={(e) => {
|
|
const { type, content } = e.detail;
|
|
const { type, content } = e.detail;
|
|
|
|
|
|
if (type === 'explain') {
|
|
if (type === 'explain') {
|
|
- dispatch('submit', {
|
|
|
|
- parentId: message.id,
|
|
|
|
- prompt: `Explain this section to me in more detail\n\n\`\`\`\n${content}\n\`\`\``
|
|
|
|
- });
|
|
|
|
|
|
+ submitMessage(
|
|
|
|
+ message.id,
|
|
|
|
+ `Explain this section to me in more detail\n\n\`\`\`\n${content}\n\`\`\``
|
|
|
|
+ );
|
|
} else if (type === 'ask') {
|
|
} else if (type === 'ask') {
|
|
const input = e.detail?.input ?? '';
|
|
const input = e.detail?.input ?? '';
|
|
- dispatch('submit', {
|
|
|
|
- parentId: message.id,
|
|
|
|
- prompt: `\`\`\`\n${content}\n\`\`\`\n${input}`
|
|
|
|
- });
|
|
|
|
|
|
+ submitMessage(message.id, `\`\`\`\n${content}\n\`\`\`\n${input}`);
|
|
}
|
|
}
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
@@ -1019,21 +1019,6 @@
|
|
disabled={feedbackLoading}
|
|
disabled={feedbackLoading}
|
|
on:click={async () => {
|
|
on:click={async () => {
|
|
await feedbackHandler(1);
|
|
await feedbackHandler(1);
|
|
-
|
|
|
|
- (model?.actions ?? [])
|
|
|
|
- .filter((action) => action?.__webui__ ?? false)
|
|
|
|
- .forEach((action) => {
|
|
|
|
- dispatch('action', {
|
|
|
|
- id: action.id,
|
|
|
|
- event: {
|
|
|
|
- id: 'good-response',
|
|
|
|
- data: {
|
|
|
|
- messageId: message.id
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
window.setTimeout(() => {
|
|
window.setTimeout(() => {
|
|
document
|
|
document
|
|
.getElementById(`message-feedback-${message.id}`)
|
|
.getElementById(`message-feedback-${message.id}`)
|
|
@@ -1070,21 +1055,6 @@
|
|
disabled={feedbackLoading}
|
|
disabled={feedbackLoading}
|
|
on:click={async () => {
|
|
on:click={async () => {
|
|
await feedbackHandler(-1);
|
|
await feedbackHandler(-1);
|
|
-
|
|
|
|
- (model?.actions ?? [])
|
|
|
|
- .filter((action) => action?.__webui__ ?? false)
|
|
|
|
- .forEach((action) => {
|
|
|
|
- dispatch('action', {
|
|
|
|
- id: action.id,
|
|
|
|
- event: {
|
|
|
|
- id: 'bad-response',
|
|
|
|
- data: {
|
|
|
|
- messageId: message.id
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
window.setTimeout(() => {
|
|
window.setTimeout(() => {
|
|
document
|
|
document
|
|
.getElementById(`message-feedback-${message.id}`)
|
|
.getElementById(`message-feedback-${message.id}`)
|
|
@@ -1120,20 +1090,6 @@
|
|
: 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
|
|
: 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
|
|
on:click={() => {
|
|
on:click={() => {
|
|
continueResponse();
|
|
continueResponse();
|
|
-
|
|
|
|
- (model?.actions ?? [])
|
|
|
|
- .filter((action) => action?.__webui__ ?? false)
|
|
|
|
- .forEach((action) => {
|
|
|
|
- dispatch('action', {
|
|
|
|
- id: action.id,
|
|
|
|
- event: {
|
|
|
|
- id: 'continue-response',
|
|
|
|
- data: {
|
|
|
|
- messageId: message.id
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
<svg
|
|
<svg
|
|
@@ -1157,50 +1113,52 @@
|
|
</svg>
|
|
</svg>
|
|
</button>
|
|
</button>
|
|
</Tooltip>
|
|
</Tooltip>
|
|
|
|
+ {/if}
|
|
|
|
|
|
- <Tooltip content={$i18n.t('Regenerate')} placement="bottom">
|
|
|
|
- <button
|
|
|
|
- type="button"
|
|
|
|
- class="{isLastMessage
|
|
|
|
- ? 'visible'
|
|
|
|
- : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
|
|
|
|
- on:click={() => {
|
|
|
|
- showRateComment = false;
|
|
|
|
- regenerateResponse(message);
|
|
|
|
-
|
|
|
|
- (model?.actions ?? [])
|
|
|
|
- .filter((action) => action?.__webui__ ?? false)
|
|
|
|
- .forEach((action) => {
|
|
|
|
- dispatch('action', {
|
|
|
|
- id: action.id,
|
|
|
|
- event: {
|
|
|
|
- id: 'regenerate-response',
|
|
|
|
- data: {
|
|
|
|
- messageId: message.id
|
|
|
|
- }
|
|
|
|
|
|
+ <Tooltip content={$i18n.t('Regenerate')} placement="bottom">
|
|
|
|
+ <button
|
|
|
|
+ type="button"
|
|
|
|
+ class="{isLastMessage
|
|
|
|
+ ? 'visible'
|
|
|
|
+ : 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
|
|
|
|
+ on:click={() => {
|
|
|
|
+ showRateComment = false;
|
|
|
|
+ regenerateResponse(message);
|
|
|
|
+
|
|
|
|
+ (model?.actions ?? [])
|
|
|
|
+ .filter((action) => action?.__webui__ ?? false)
|
|
|
|
+ .forEach((action) => {
|
|
|
|
+ dispatch('action', {
|
|
|
|
+ id: action.id,
|
|
|
|
+ event: {
|
|
|
|
+ id: 'regenerate-response',
|
|
|
|
+ data: {
|
|
|
|
+ messageId: message.id
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- }}
|
|
|
|
|
|
+ });
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <svg
|
|
|
|
+ xmlns="http://www.w3.org/2000/svg"
|
|
|
|
+ fill="none"
|
|
|
|
+ viewBox="0 0 24 24"
|
|
|
|
+ stroke-width="2.3"
|
|
|
|
+ stroke="currentColor"
|
|
|
|
+ class="w-4 h-4"
|
|
>
|
|
>
|
|
- <svg
|
|
|
|
- xmlns="http://www.w3.org/2000/svg"
|
|
|
|
- fill="none"
|
|
|
|
- viewBox="0 0 24 24"
|
|
|
|
- stroke-width="2.3"
|
|
|
|
- stroke="currentColor"
|
|
|
|
- class="w-4 h-4"
|
|
|
|
- >
|
|
|
|
- <path
|
|
|
|
- stroke-linecap="round"
|
|
|
|
- stroke-linejoin="round"
|
|
|
|
- d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
|
|
|
|
- />
|
|
|
|
- </svg>
|
|
|
|
- </button>
|
|
|
|
- </Tooltip>
|
|
|
|
|
|
+ <path
|
|
|
|
+ stroke-linecap="round"
|
|
|
|
+ stroke-linejoin="round"
|
|
|
|
+ d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
|
|
|
|
+ />
|
|
|
|
+ </svg>
|
|
|
|
+ </button>
|
|
|
|
+ </Tooltip>
|
|
|
|
|
|
- {#each (model?.actions ?? []).filter((action) => !(action?.__webui__ ?? false)) as action}
|
|
|
|
|
|
+ {#if isLastMessage}
|
|
|
|
+ {#each model?.actions ?? [] as action}
|
|
<Tooltip content={action.name} placement="bottom">
|
|
<Tooltip content={action.name} placement="bottom">
|
|
<button
|
|
<button
|
|
type="button"
|
|
type="button"
|
|
@@ -1208,7 +1166,7 @@
|
|
? 'visible'
|
|
? 'visible'
|
|
: 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
|
|
: 'invisible group-hover:visible'} p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg dark:hover:text-white hover:text-black transition regenerate-response-button"
|
|
on:click={() => {
|
|
on:click={() => {
|
|
- dispatch('action', action.id);
|
|
|
|
|
|
+ actionMessage(action.id);
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
{#if action.icon_url}
|
|
{#if action.icon_url}
|
|
@@ -1242,22 +1200,6 @@
|
|
comment: e.detail.comment,
|
|
comment: e.detail.comment,
|
|
reason: e.detail.reason
|
|
reason: e.detail.reason
|
|
});
|
|
});
|
|
-
|
|
|
|
- (model?.actions ?? [])
|
|
|
|
- .filter((action) => action?.__webui__ ?? false)
|
|
|
|
- .forEach((action) => {
|
|
|
|
- dispatch('action', {
|
|
|
|
- id: action.id,
|
|
|
|
- event: {
|
|
|
|
- id: 'rate-comment',
|
|
|
|
- data: {
|
|
|
|
- messageId: message.id,
|
|
|
|
- comment: e.detail.comment,
|
|
|
|
- reason: e.detail.reason
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
{/if}
|
|
{/if}
|