Merge pull request #498 from bhulston/fix/chat-imports

Feat: Add ChatGPT import functionality
This commit is contained in:
Timothy Jaeryang Baek 2024-01-17 14:50:28 -08:00 committed by GitHub
commit 578e78cb39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 110 additions and 21 deletions

View file

@ -21,7 +21,7 @@
import { WEB_UI_VERSION, WEBUI_API_BASE_URL } from '$lib/constants';
import { config, models, settings, user, chats } from '$lib/stores';
import { splitStream, getGravatarURL } from '$lib/utils';
import { splitStream, getGravatarURL, getImportOrigin, convertOpenAIChats } from '$lib/utils';
import Advanced from './Settings/Advanced.svelte';
import Modal from '../common/Modal.svelte';
@ -132,6 +132,13 @@
reader.onload = (event) => {
let chats = JSON.parse(event.target.result);
console.log(chats);
if (getImportOrigin(chats) == 'openai') {
try {
chats = convertOpenAIChats(chats);
} catch (error) {
console.log('Unable to import chats:', error);
}
}
importChats(chats);
};