mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-23 09:10:55 -05:00
refac
This commit is contained in:
@@ -6,18 +6,24 @@
|
||||
import ProfileImage from '../Messages/ProfileImage.svelte';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import Heart from '$lib/components/icons/Heart.svelte';
|
||||
import { getOutputText } from '../Messages/structuredOutput';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
type $$Props = NodeProps;
|
||||
export let data: $$Props['data'];
|
||||
|
||||
const getMessageContent = (nodeData: any) =>
|
||||
getOutputText(nodeData?.message?.output) || nodeData?.message?.content || '';
|
||||
|
||||
$: messageContent = getMessageContent(data);
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="px-4 py-3 shadow-md rounded-xl dark:bg-black bg-white border border-gray-100 dark:border-gray-900 w-60 h-20 group"
|
||||
>
|
||||
<Tooltip
|
||||
content={data?.message?.error ? data.message.error.content : data.message.content}
|
||||
content={data?.message?.error ? data.message.error.content : messageContent}
|
||||
class="w-full"
|
||||
allowHTML={false}
|
||||
>
|
||||
@@ -37,7 +43,7 @@
|
||||
{#if data?.message?.error}
|
||||
<div class="text-red-500 line-clamp-2 text-xs mt-0.5">{data.message.error.content}</div>
|
||||
{:else}
|
||||
<div class="text-gray-500 line-clamp-2 text-xs mt-0.5">{data.message.content}</div>
|
||||
<div class="text-gray-500 line-clamp-2 text-xs mt-0.5">{messageContent}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,7 +83,7 @@
|
||||
{data.message.error.content}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="text-gray-500 line-clamp-2 text-xs mt-0.5">{data.message.content}</div>
|
||||
<div class="text-gray-500 line-clamp-2 text-xs mt-0.5">{messageContent}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import { downloadChatAsPDF } from '$lib/apis/utils';
|
||||
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
||||
import { getOutputText } from '$lib/components/chat/Messages/structuredOutput';
|
||||
|
||||
import {
|
||||
showControls,
|
||||
@@ -59,7 +60,8 @@
|
||||
const history = chat.chat.history;
|
||||
const messages = createMessagesList(history, history.currentId);
|
||||
const chatText = messages.reduce((a, message, i, arr) => {
|
||||
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
||||
const content = getOutputText(message.output) || message.content || '';
|
||||
return `${a}### ${message.role.toUpperCase()}\n${content}\n\n`;
|
||||
}, '');
|
||||
|
||||
return chatText.trim();
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import calendar from 'dayjs/plugin/calendar';
|
||||
import Loader from '../common/Loader.svelte';
|
||||
import { createMessagesList } from '$lib/utils';
|
||||
import { getOutputText } from '$lib/components/chat/Messages/structuredOutput';
|
||||
import {
|
||||
config,
|
||||
user,
|
||||
@@ -204,14 +205,14 @@
|
||||
let msgList = [];
|
||||
|
||||
if (history?.messages && history?.currentId) {
|
||||
msgList = createMessagesList(history, history.currentId).map((m) => ({
|
||||
msgList = createMessagesList(history, history.currentId).map((m: any) => ({
|
||||
role: m.role,
|
||||
content: m.content
|
||||
content: getOutputText(m.output) || m.content || ''
|
||||
}));
|
||||
} else {
|
||||
msgList = (chatContent?.messages ?? []).map((m) => ({
|
||||
msgList = (chatContent?.messages ?? []).map((m: any) => ({
|
||||
role: m.role,
|
||||
content: m.content
|
||||
content: getOutputText(m.output) || m.content || ''
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { generateTitle } from '$lib/apis';
|
||||
import { createMessagesList } from '$lib/utils';
|
||||
import { getOutputText } from '$lib/components/chat/Messages/structuredOutput';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@@ -361,14 +362,14 @@
|
||||
const history = chatContent?.history;
|
||||
let messages = [];
|
||||
if (history?.messages && history?.currentId) {
|
||||
messages = createMessagesList(history, history.currentId).map((message) => ({
|
||||
messages = createMessagesList(history, history.currentId).map((message: any) => ({
|
||||
role: message.role,
|
||||
content: message.content
|
||||
content: getOutputText(message.output) || message.content || ''
|
||||
}));
|
||||
} else {
|
||||
messages = (chatContent?.messages ?? []).map((message) => ({
|
||||
messages = (chatContent?.messages ?? []).map((message: any) => ({
|
||||
role: message.role,
|
||||
content: message.content
|
||||
content: getOutputText(message.output) || message.content || ''
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
} from '$lib/apis/chats';
|
||||
import { chats, folders, settings, theme, user } from '$lib/stores';
|
||||
import { createMessagesList } from '$lib/utils';
|
||||
import { getOutputText } from '$lib/components/chat/Messages/structuredOutput';
|
||||
import { downloadChatAsPDF } from '$lib/apis/utils';
|
||||
import Download from '$lib/components/icons/Download.svelte';
|
||||
import Folder from '$lib/components/icons/Folder.svelte';
|
||||
@@ -61,7 +62,8 @@
|
||||
const history = chat.chat.history;
|
||||
const messages = createMessagesList(history, history.currentId);
|
||||
const chatText = messages.reduce((a, message, i, arr) => {
|
||||
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
||||
const content = getOutputText(message.output) || message.content || '';
|
||||
return `${a}### ${message.role.toUpperCase()}\n${content}\n\n`;
|
||||
}, '');
|
||||
|
||||
return chatText.trim();
|
||||
|
||||
Reference in New Issue
Block a user