refac
This commit is contained in:
1 parent
0016266c06
commit
4b08d65597
5 files changed
+25
-13
No files matched your search
@@ -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