forked from open-webui/open-webui
feat: messages refac
This commit is contained in:
parent
f91a6b63d1
commit
b916f1b07d
3 changed files with 26 additions and 11 deletions
|
@ -96,7 +96,17 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmEditResponseMessage = async (messageId, content) => {
|
const confirmEditResponseMessage = async (messageId, content) => {
|
||||||
|
history.messages[messageId].originalContent = history.messages[messageId].content;
|
||||||
history.messages[messageId].content = content;
|
history.messages[messageId].content = content;
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
await updateChatById(localStorage.token, chatId, {
|
||||||
|
messages: messages,
|
||||||
|
history: history
|
||||||
|
});
|
||||||
|
|
||||||
|
await chats.set(await getChatList(localStorage.token));
|
||||||
};
|
};
|
||||||
|
|
||||||
const rateMessage = async (messageId, rating) => {
|
const rateMessage = async (messageId, rating) => {
|
||||||
|
@ -225,6 +235,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<ResponseMessage
|
<ResponseMessage
|
||||||
{message}
|
{message}
|
||||||
|
modelfiles={selectedModelfiles}
|
||||||
siblings={history.messages[message.parentId]?.childrenIds ?? []}
|
siblings={history.messages[message.parentId]?.childrenIds ?? []}
|
||||||
isLastMessage={messageIdx + 1 === messages.length}
|
isLastMessage={messageIdx + 1 === messages.length}
|
||||||
{confirmEditResponseMessage}
|
{confirmEditResponseMessage}
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
export let copyToClipboard: Function;
|
export let copyToClipboard: Function;
|
||||||
export let regenerateResponse: Function;
|
export let regenerateResponse: Function;
|
||||||
|
|
||||||
let selectedModelfile = '';
|
|
||||||
|
|
||||||
let edit = false;
|
let edit = false;
|
||||||
let editedContent = '';
|
let editedContent = '';
|
||||||
|
|
||||||
|
@ -42,19 +40,14 @@
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
if (tooltipInstance) {
|
if (tooltipInstance) {
|
||||||
console.log(tooltipInstance);
|
|
||||||
tooltipInstance[0].destroy();
|
tooltipInstance[0].destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('rendering message');
|
|
||||||
|
|
||||||
renderLatex();
|
renderLatex();
|
||||||
hljs.highlightAll();
|
hljs.highlightAll();
|
||||||
createCopyCodeBlockButton();
|
createCopyCodeBlockButton();
|
||||||
|
|
||||||
if (message.info) {
|
if (message.info) {
|
||||||
console.log(message);
|
|
||||||
|
|
||||||
tooltipInstance = tippy(`#info-${message.id}`, {
|
tooltipInstance = tippy(`#info-${message.id}`, {
|
||||||
content: `<span class="text-xs" id="tooltip-${message.id}">token/s: ${
|
content: `<span class="text-xs" id="tooltip-${message.id}">token/s: ${
|
||||||
`${
|
`${
|
||||||
|
@ -214,12 +207,12 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class=" flex w-full message-{message.id}">
|
<div class=" flex w-full message-{message.id}">
|
||||||
<ProfileImage src={selectedModelfile?.imageUrl ?? '/favicon.png'} />
|
<ProfileImage src={modelfiles[message.model]?.imageUrl ?? '/favicon.png'} />
|
||||||
|
|
||||||
<div class="w-full overflow-hidden">
|
<div class="w-full overflow-hidden">
|
||||||
<Name>
|
<Name>
|
||||||
{#if selectedModelfile}
|
{#if message.model in modelfiles}
|
||||||
{selectedModelfile.title}
|
{modelfiles[message.model]?.title}
|
||||||
{:else}
|
{:else}
|
||||||
Ollama <span class=" text-gray-500 text-sm font-medium"
|
Ollama <span class=" text-gray-500 text-sm font-medium"
|
||||||
>{message.model ? ` ${message.model}` : ''}</span
|
>{message.model ? ` ${message.model}` : ''}</span
|
||||||
|
|
|
@ -31,6 +31,17 @@
|
||||||
? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
|
? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
let selectedModelfiles = {};
|
||||||
|
$: selectedModelfiles = selectedModels.reduce((a, tagName, i, arr) => {
|
||||||
|
const modelfile =
|
||||||
|
$modelfiles.filter((modelfile) => modelfile.tagName === tagName)?.at(0) ?? undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...a,
|
||||||
|
...(modelfile && { [tagName]: modelfile })
|
||||||
|
};
|
||||||
|
}, {});
|
||||||
|
|
||||||
let chat = null;
|
let chat = null;
|
||||||
|
|
||||||
let title = '';
|
let title = '';
|
||||||
|
@ -643,7 +654,7 @@
|
||||||
<Messages
|
<Messages
|
||||||
chatId={$chatId}
|
chatId={$chatId}
|
||||||
{selectedModels}
|
{selectedModels}
|
||||||
{selectedModelfile}
|
{selectedModelfiles}
|
||||||
bind:history
|
bind:history
|
||||||
bind:messages
|
bind:messages
|
||||||
bind:autoScroll
|
bind:autoScroll
|
||||||
|
|
Loading…
Reference in a new issue