Commit d12599b2 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

refac

parent 1482119a
<script lang="ts">
import toast from 'svelte-french-toast';
import queue from 'async/queue';
import fileSaver from 'file-saver';
const { saveAs } = fileSaver;
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
import { config, models, settings, user, chats } from '$lib/stores';
import { splitStream, getGravatarURL } from '$lib/utils';
import queue from 'async/queue';
import {
getOllamaVersion,
......@@ -17,14 +16,16 @@
createModel,
deleteModel
} from '$lib/apis/ollama';
import { updateUserPassword } from '$lib/apis/auths';
import { createNewChat, deleteAllChats, getAllChats, getChatList } from '$lib/apis/chats';
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 Advanced from './Settings/Advanced.svelte';
import Modal from '../common/Modal.svelte';
import { updateUserPassword } from '$lib/apis/auths';
import { goto } from '$app/navigation';
import Page from '../../../routes/(app)/+page.svelte';
import {
getOpenAIKey,
getOpenAIModels,
......@@ -50,13 +51,6 @@
let theme = 'dark';
let notificationEnabled = false;
let system = '';
const MAX_PARALLEL_DOWNLOADS = 3;
const modelDownloadQueue = queue(
(task: { modelName: string }, cb) =>
pullModelHandlerProcessor({ modelName: task.modelName, callback: cb }),
MAX_PARALLEL_DOWNLOADS
);
let modelDownloadStatus: Record<string, any> = {};
// Advanced
let requestFormat = '';
......@@ -78,8 +72,15 @@
};
// Models
let modelTransferring = false;
const MAX_PARALLEL_DOWNLOADS = 3;
const modelDownloadQueue = queue(
(task: { modelName: string }, cb) =>
pullModelHandlerProcessor({ modelName: task.modelName, callback: cb }),
MAX_PARALLEL_DOWNLOADS
);
let modelDownloadStatus: Record<string, any> = {};
let modelTransferring = false;
let modelTag = '';
let digest = '';
let pullProgress = null;
......@@ -94,7 +95,6 @@
let deleteModelTag = '';
// External
let OPENAI_API_KEY = '';
let OPENAI_API_BASE_URL = '';
......@@ -111,21 +111,18 @@
let importFiles;
let showDeleteConfirm = false;
const importChats = async (_chats) => {
for (const chat of _chats) {
console.log(chat);
await createNewChat(localStorage.token, chat);
}
// Auth
let authEnabled = false;
let authType = 'Basic';
let authContent = '';
await chats.set(await getChatList(localStorage.token));
};
// Account
let currentPassword = '';
let newPassword = '';
let newPasswordConfirm = '';
const exportChats = async () => {
let blob = new Blob([JSON.stringify(await getAllChats(localStorage.token))], {
type: 'application/json'
});
saveAs(blob, `chat-export-${Date.now()}.json`);
};
// About
let ollamaVersion = '';
$: if (importFiles) {
console.log(importFiles);
......@@ -140,25 +137,28 @@
reader.readAsText(importFiles[0]);
}
const importChats = async (_chats) => {
for (const chat of _chats) {
console.log(chat);
await createNewChat(localStorage.token, chat);
}
await chats.set(await getChatList(localStorage.token));
};
const exportChats = async () => {
let blob = new Blob([JSON.stringify(await getAllChats(localStorage.token))], {
type: 'application/json'
});
saveAs(blob, `chat-export-${Date.now()}.json`);
};
const deleteChats = async () => {
await goto('/');
await deleteAllChats(localStorage.token);
await chats.set(await getChatList(localStorage.token));
};
// Auth
let authEnabled = false;
let authType = 'Basic';
let authContent = '';
// Account
let currentPassword = '';
let newPassword = '';
let newPasswordConfirm = '';
// About
let ollamaVersion = '';
const updateOllamaAPIUrlHandler = async () => {
API_BASE_URL = await updateOllamaAPIUrl(localStorage.token, API_BASE_URL);
const _models = await getModels('ollama');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment