fix: chat pdf, txt export issue

This commit is contained in:
Timothy J. Baek
2024-09-26 20:59:25 +02:00
parent 15bd5ebd7b
commit 1d225dd804
6 changed files with 48 additions and 50 deletions

View File

@@ -11,7 +11,6 @@
import MultiResponseMessages from './MultiResponseMessages.svelte';
import ResponseMessage from './ResponseMessage.svelte';
import UserMessage from './UserMessage.svelte';
import { updateChatById } from '$lib/apis/chats';
export let chatId;
export let idx = 0;
@@ -21,9 +20,6 @@
export let user;
export let updateChatHistory;
export let chatActionHandler;
export let showPreviousMessage;
export let showNextMessage;
@@ -81,18 +77,10 @@
{continueResponse}
{regenerateResponse}
on:action={async (e) => {
console.log('action', e);
const message = history.messages[messageId];
if (typeof e.detail === 'string') {
await chatActionHandler(chatId, e.detail, message.model, message.id);
} else {
const { id, event } = e.detail;
await chatActionHandler(chatId, id, message.model, message.id, event);
}
dispatch('action', e.detail);
}}
on:update={async (e) => {
console.log('update', e);
updateChatHistory();
dispatch('update');
}}
on:save={async (e) => {
console.log('save', e);
@@ -100,13 +88,9 @@
const message = e.detail;
if (message) {
history.messages[message.id] = message;
await updateChatById(localStorage.token, chatId, {
history: history
});
dispatch('update');
} else {
await updateChatById(localStorage.token, chatId, {
history: history
});
dispatch('update');
}
}}
{readOnly}
@@ -123,40 +107,24 @@
{regenerateResponse}
{mergeResponses}
on:action={async (e) => {
console.log('action', e);
const message = history.messages[messageId];
if (typeof e.detail === 'string') {
await chatActionHandler(chatId, e.detail, message.model, message.id);
} else {
const { id, event } = e.detail;
await chatActionHandler(chatId, id, message.model, message.id, event);
}
dispatch('action', e.detail);
}}
on:update={async (e) => {
console.log('update', e);
updateChatHistory();
dispatch('update');
}}
on:save={async (e) => {
console.log('save', e);
const message = e.detail;
if (message) {
history.messages[message.id] = message;
await updateChatById(localStorage.token, chatId, {
history: history
});
dispatch('update');
} else {
await updateChatById(localStorage.token, chatId, {
history: history
});
dispatch('update');
}
}}
on:change={async () => {
await tick();
await updateChatById(localStorage.token, chatId, {
history: history
});
dispatch('update');
dispatch('scroll');
}}
{readOnly}