SettingsModal.svelte 69.1 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
<script lang="ts">
Timothy J. Baek's avatar
Timothy J. Baek committed
2
	import toast from 'svelte-french-toast';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
3
	import queue from 'async/queue';
Timothy J. Baek's avatar
Timothy J. Baek committed
4
5
	import fileSaver from 'file-saver';
	const { saveAs } = fileSaver;
6

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
7
	import { goto } from '$app/navigation';
Timothy J. Baek's avatar
Timothy J. Baek committed
8
9
	import { onMount } from 'svelte';

Timothy J. Baek's avatar
Timothy J. Baek committed
10
	import {
11
12
13
14
15
16
17
18
		getOllamaVersion,
		getOllamaModels,
		getOllamaAPIUrl,
		updateOllamaAPIUrl,
		pullModel,
		createModel,
		deleteModel
	} from '$lib/apis/ollama';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
19
	import { updateUserPassword } from '$lib/apis/auths';
20
21
22
23
24
25
26
	import {
		createNewChat,
		deleteAllChats,
		getAllChats,
		getAllUserChats,
		getChatList
	} from '$lib/apis/chats';
27
	import { WEB_UI_VERSION, WEBUI_API_BASE_URL } from '$lib/constants';
Timothy J. Baek's avatar
Timothy J. Baek committed
28

29
	import { config, models, voices, settings, user, chats } from '$lib/stores';
Timothy J. Baek's avatar
Timothy J. Baek committed
30
	import { splitStream, getGravatarURL, getImportOrigin, convertOpenAIChats } from '$lib/utils';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
31

32
	import Advanced from './Settings/Advanced.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
33
	import Modal from '../common/Modal.svelte';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
34

35
36
37
38
39
40
41
	import {
		getOpenAIKey,
		getOpenAIModels,
		getOpenAIUrl,
		updateOpenAIKey,
		updateOpenAIUrl
	} from '$lib/apis/openai';
42
	import { resetVectorDB } from '$lib/apis/rag';
43
44
	import { setDefaultPromptSuggestions } from '$lib/apis/configs';
	import { getBackendConfig } from '$lib/apis';
45
46
	import UpdatePassword from './Settings/Account/UpdatePassword.svelte';
	import Account from './Settings/Account.svelte';
47

Timothy J. Baek's avatar
Timothy J. Baek committed
48
	export let show = false;
49
50
51
52

	const saveSettings = async (updated) => {
		console.log(updated);
		await settings.set({ ...$settings, ...updated });
53
		await models.set(await getModels());
54
55
		localStorage.setItem('settings', JSON.stringify($settings));
	};
56

57
58
59
	let selectedTab = 'general';

	// General
60
	let API_BASE_URL = '';
61
	let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'];
Timothy J. Baek's avatar
Timothy J. Baek committed
62
	let theme = 'dark';
Timothy J. Baek's avatar
Timothy J. Baek committed
63
	let notificationEnabled = false;
64
	let system = '';
65
66

	// Advanced
67
	let requestFormat = '';
68
69
70
71
72
73
74
75
76
77
78
79
80
	let options = {
		// Advanced
		seed: 0,
		temperature: '',
		repeat_penalty: '',
		repeat_last_n: '',
		mirostat: '',
		mirostat_eta: '',
		mirostat_tau: '',
		top_k: '',
		top_p: '',
		stop: '',
		tfs_z: '',
81
82
		num_ctx: '',
		num_predict: ''
83
	};
84

85
	// Models
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
86
87
88
89
90
91
92
	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> = {};
93

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
94
	let modelTransferring = false;
95
	let modelTag = '';
96
97
98
99
	let digest = '';
	let pullProgress = null;

	let modelUploadMode = 'file';
Timothy J. Baek's avatar
Timothy J. Baek committed
100
	let modelInputFile = '';
101
	let modelFileUrl = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
102
	let modelFileContent = `TEMPLATE """{{ .System }}\nUSER: {{ .Prompt }}\nASSSISTANT: """\nPARAMETER num_ctx 4096\nPARAMETER stop "</s>"\nPARAMETER stop "USER:"\nPARAMETER stop "ASSSISTANT:"`;
103
104
	let modelFileDigest = '';
	let uploadProgress = null;
Timothy J. Baek's avatar
Timothy J. Baek committed
105

106
107
	let deleteModelTag = '';

108
109
110
111
	// External
	let OPENAI_API_KEY = '';
	let OPENAI_API_BASE_URL = '';

112
113
114
	// Interface
	let promptSuggestions = [];

Timothy J. Baek's avatar
Timothy J. Baek committed
115
	// Addons
116
	let titleAutoGenerate = true;
117
	let speechAutoSend = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
118
	let responseAutoCopy = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
119

Timothy J. Baek's avatar
Timothy J. Baek committed
120
	let gravatarEmail = '';
121
	let titleAutoGenerateModel = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
122

123
124
125
	// Voice
	let speakVoice = '';

126
	// Chats
127
	let saveChatHistory = true;
128
	let importFiles;
Timothy J. Baek's avatar
Timothy J. Baek committed
129
	let showDeleteConfirm = false;
130

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
131
132
133
134
	// Auth
	let authEnabled = false;
	let authType = 'Basic';
	let authContent = '';
135

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
136
	// Account
137
	let profileImageUrl = '';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
138
139
140
	let currentPassword = '';
	let newPassword = '';
	let newPasswordConfirm = '';
141

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
142
143
	// About
	let ollamaVersion = '';
144
145
146
147
148
149
150
151

	$: if (importFiles) {
		console.log(importFiles);

		let reader = new FileReader();
		reader.onload = (event) => {
			let chats = JSON.parse(event.target.result);
			console.log(chats);
Timothy J. Baek's avatar
Timothy J. Baek committed
152
			if (getImportOrigin(chats) == 'openai') {
153
				try {
Timothy J. Baek's avatar
Timothy J. Baek committed
154
					chats = convertOpenAIChats(chats);
155
				} catch (error) {
Timothy J. Baek's avatar
Timothy J. Baek committed
156
					console.log('Unable to import chats:', error);
157
				}
158
			}
159
160
161
			importChats(chats);
		};

162
163
164
		if (importFiles.length > 0) {
			reader.readAsText(importFiles[0]);
		}
165
166
	}

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
167
168
169
	const importChats = async (_chats) => {
		for (const chat of _chats) {
			console.log(chat);
170
171
172
173
174
175

			if (chat.chat) {
				await createNewChat(localStorage.token, chat.chat);
			} else {
				await createNewChat(localStorage.token, chat);
			}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
176
177
178
179
180
181
182
183
184
185
186
187
		}

		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`);
	};

188
189
190
191
192
193
194
	const exportAllUserChats = async () => {
		let blob = new Blob([JSON.stringify(await getAllUserChats(localStorage.token))], {
			type: 'application/json'
		});
		saveAs(blob, `all-chats-export-${Date.now()}.json`);
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
195
196
197
198
199
200
	const deleteChats = async () => {
		await goto('/');
		await deleteAllChats(localStorage.token);
		await chats.set(await getChatList(localStorage.token));
	};

201
202
203
	const updateOllamaAPIUrlHandler = async () => {
		API_BASE_URL = await updateOllamaAPIUrl(localStorage.token, API_BASE_URL);
		const _models = await getModels('ollama');
204

Timothy J. Baek's avatar
Timothy J. Baek committed
205
		if (_models.length > 0) {
206
			toast.success('Server connection verified');
Timothy J. Baek's avatar
Timothy J. Baek committed
207
			await models.set(_models);
208
209
210
		}
	};

211
212
213
214
215
216
217
	const updateOpenAIHandler = async () => {
		OPENAI_API_BASE_URL = await updateOpenAIUrl(localStorage.token, OPENAI_API_BASE_URL);
		OPENAI_API_KEY = await updateOpenAIKey(localStorage.token, OPENAI_API_KEY);

		await models.set(await getModels());
	};

218
219
220
221
222
	const updateInterfaceHandler = async () => {
		promptSuggestions = await setDefaultPromptSuggestions(localStorage.token, promptSuggestions);
		await config.set(await getBackendConfig());
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
223
224
225
226
227
228
229
230
231
232
233
234
235
	const toggleTheme = async () => {
		if (theme === 'dark') {
			theme = 'light';
		} else {
			theme = 'dark';
		}

		localStorage.theme = theme;

		document.documentElement.classList.remove(theme === 'dark' ? 'light' : 'dark');
		document.documentElement.classList.add(theme);
	};

236
	const toggleRequestFormat = async () => {
237
238
239
240
241
242
243
244
245
		if (requestFormat === '') {
			requestFormat = 'json';
		} else {
			requestFormat = '';
		}

		saveSettings({ requestFormat: requestFormat !== '' ? requestFormat : undefined });
	};

246
247
248
249
250
	const toggleSpeechAutoSend = async () => {
		speechAutoSend = !speechAutoSend;
		saveSettings({ speechAutoSend: speechAutoSend });
	};

251
252
253
254
255
	const toggleTitleAutoGenerate = async () => {
		titleAutoGenerate = !titleAutoGenerate;
		saveSettings({ titleAutoGenerate: titleAutoGenerate });
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
256
	const toggleNotification = async () => {
Timothy J. Baek's avatar
Timothy J. Baek committed
257
258
259
		const permission = await Notification.requestPermission();

		if (permission === 'granted') {
Timothy J. Baek's avatar
Timothy J. Baek committed
260
261
			notificationEnabled = !notificationEnabled;
			saveSettings({ notificationEnabled: notificationEnabled });
Timothy J. Baek's avatar
Timothy J. Baek committed
262
263
264
265
266
267
268
		} else {
			toast.error(
				'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
			);
		}
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
	const toggleResponseAutoCopy = async () => {
		const permission = await navigator.clipboard
			.readText()
			.then(() => {
				return 'granted';
			})
			.catch(() => {
				return '';
			});

		console.log(permission);

		if (permission === 'granted') {
			responseAutoCopy = !responseAutoCopy;
			saveSettings({ responseAutoCopy: responseAutoCopy });
		} else {
			toast.error(
				'Clipboard write permission denied. Please check your browser settings to grant the necessary access.'
			);
		}
	};

291
292
	const toggleSaveChatHistory = async () => {
		saveChatHistory = !saveChatHistory;
293
294
295
296
297
		console.log(saveChatHistory);

		if (saveChatHistory === false) {
			await goto('/');
		}
298
		saveSettings({ saveChatHistory: saveChatHistory });
Timothy J. Baek's avatar
Timothy J. Baek committed
299
300
	};

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
301
302
303
304
305
	const pullModelHandlerProcessor = async (opts: { modelName: string; callback: Function }) => {
		const res = await pullModel(localStorage.token, opts.modelName).catch((error) => {
			opts.callback({ success: false, error, modelName: opts.modelName });
			return null;
		});
306

307
308
309
310
311
		if (res) {
			const reader = res.body
				.pipeThrough(new TextDecoderStream())
				.pipeThrough(splitStream('\n'))
				.getReader();
312

313
314
			while (true) {
				try {
315
316
					const { value, done } = await reader.read();
					if (done) break;
317

318
					let lines = value.split('\n');
319

320
321
322
323
324
325
326
327
328
329
					for (const line of lines) {
						if (line !== '') {
							let data = JSON.parse(line);
							if (data.error) {
								throw data.error;
							}
							if (data.detail) {
								throw data.detail;
							}
							if (data.status) {
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
330
331
								if (data.digest) {
									let downloadProgress = 0;
332
									if (data.completed) {
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
333
										downloadProgress = Math.round((data.completed / data.total) * 1000) / 10;
334
									} else {
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
335
										downloadProgress = 100;
336
									}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
337
338
339
340
									modelDownloadStatus[opts.modelName] = {
										pullProgress: downloadProgress,
										digest: data.digest
									};
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
341
342
								} else {
									toast.success(data.status);
343
344
345
346
								}
							}
						}
					}
347
348
				} catch (error) {
					console.log(error);
Timothy J. Baek's avatar
Timothy J. Baek committed
349
350
351
					if (typeof error !== 'string') {
						error = error.message;
					}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
352
					opts.callback({ success: false, error, modelName: opts.modelName });
353
354
				}
			}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
355
			opts.callback({ success: true, modelName: opts.modelName });
356
357
358
		}
	};

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
359
	const pullModelHandler = async () => {
Anuraag Jain's avatar
Anuraag Jain committed
360
361
362
		const sanitizedModelTag = modelTag.trim();
		if (modelDownloadStatus[sanitizedModelTag]) {
			toast.error(`Model '${sanitizedModelTag}' is already in queue for downloading.`);
Anuraag Jain's avatar
Anuraag Jain committed
363
364
			return;
		}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
365
		if (Object.keys(modelDownloadStatus).length === 3) {
Timothy J. Baek's avatar
Timothy J. Baek committed
366
			toast.error('Maximum of 3 models can be downloaded simultaneously. Please try again later.');
Anuraag Jain's avatar
Anuraag Jain committed
367
368
			return;
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
369

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
370
		modelTransferring = true;
Timothy J. Baek's avatar
Timothy J. Baek committed
371

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
372
		modelDownloadQueue.push(
Anuraag Jain's avatar
Anuraag Jain committed
373
			{ modelName: sanitizedModelTag },
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
374
375
376
377
			async (data: { modelName: string; success: boolean; error?: Error }) => {
				const { modelName } = data;
				// Remove the downloaded model
				delete modelDownloadStatus[modelName];
Timothy J. Baek's avatar
Timothy J. Baek committed
378

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
379
				console.log(data);
Timothy J. Baek's avatar
Timothy J. Baek committed
380

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
381
382
				if (!data.success) {
					toast.error(data.error);
Timothy J. Baek's avatar
Timothy J. Baek committed
383
				} else {
Timothy J. Baek's avatar
Timothy J. Baek committed
384
					toast.success(`Model '${modelName}' has been successfully downloaded.`);
Timothy J. Baek's avatar
Timothy J. Baek committed
385

386
387
388
389
					const notification = new Notification(`Ollama`, {
						body: `Model '${modelName}' has been successfully downloaded.`,
						icon: '/favicon.png'
					});
Timothy J. Baek's avatar
Timothy J. Baek committed
390

Timothy J. Baek's avatar
Timothy J. Baek committed
391
					models.set(await getModels());
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
392
393
394
				}
			}
		);
Timothy J. Baek's avatar
Timothy J. Baek committed
395

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
396
397
		modelTag = '';
		modelTransferring = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
398
399
400
	};

	const uploadModelHandler = async () => {
401
		modelTransferring = true;
402
		uploadProgress = 0;
Timothy J. Baek's avatar
Timothy J. Baek committed
403

Timothy J. Baek's avatar
Timothy J. Baek committed
404
		let uploaded = false;
405
406
		let fileResponse = null;
		let name = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
407

408
409
410
411
		if (modelUploadMode === 'file') {
			const file = modelInputFile[0];
			const formData = new FormData();
			formData.append('file', file);
Timothy J. Baek's avatar
Timothy J. Baek committed
412

413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
			fileResponse = await fetch(`${WEBUI_API_BASE_URL}/utils/upload`, {
				method: 'POST',
				headers: {
					...($user && { Authorization: `Bearer ${localStorage.token}` })
				},
				body: formData
			}).catch((error) => {
				console.log(error);
				return null;
			});
		} else {
			fileResponse = await fetch(`${WEBUI_API_BASE_URL}/utils/download?url=${modelFileUrl}`, {
				method: 'GET',
				headers: {
					...($user && { Authorization: `Bearer ${localStorage.token}` })
				}
			}).catch((error) => {
				console.log(error);
				return null;
			});
		}

		if (fileResponse && fileResponse.ok) {
			const reader = fileResponse.body
Timothy J. Baek's avatar
Timothy J. Baek committed
437
438
439
440
441
442
443
444
445
446
447
448
449
450
				.pipeThrough(new TextDecoderStream())
				.pipeThrough(splitStream('\n'))
				.getReader();

			while (true) {
				const { value, done } = await reader.read();
				if (done) break;

				try {
					let lines = value.split('\n');

					for (const line of lines) {
						if (line !== '') {
							let data = JSON.parse(line.replace(/^data: /, ''));
451
452
453
454

							if (data.progress) {
								uploadProgress = data.progress;
							}
Timothy J. Baek's avatar
Timothy J. Baek committed
455
456
457
458
459
460

							if (data.error) {
								throw data.error;
							}

							if (data.done) {
461
462
								modelFileDigest = data.blob;
								name = data.name;
Timothy J. Baek's avatar
Timothy J. Baek committed
463
464
465
466
467
468
469
470
471
472
473
								uploaded = true;
							}
						}
					}
				} catch (error) {
					console.log(error);
				}
			}
		}

		if (uploaded) {
474
475
476
477
478
			const res = await createModel(
				localStorage.token,
				`${name}:latest`,
				`FROM @${modelFileDigest}\n${modelFileContent}`
			);
Timothy J. Baek's avatar
Timothy J. Baek committed
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534

			if (res && res.ok) {
				const reader = res.body
					.pipeThrough(new TextDecoderStream())
					.pipeThrough(splitStream('\n'))
					.getReader();

				while (true) {
					const { value, done } = await reader.read();
					if (done) break;

					try {
						let lines = value.split('\n');

						for (const line of lines) {
							if (line !== '') {
								console.log(line);
								let data = JSON.parse(line);
								console.log(data);

								if (data.error) {
									throw data.error;
								}
								if (data.detail) {
									throw data.detail;
								}

								if (data.status) {
									if (
										!data.digest &&
										!data.status.includes('writing') &&
										!data.status.includes('sha256')
									) {
										toast.success(data.status);
									} else {
										if (data.digest) {
											digest = data.digest;

											if (data.completed) {
												pullProgress = Math.round((data.completed / data.total) * 1000) / 10;
											} else {
												pullProgress = 100;
											}
										}
									}
								}
							}
						}
					} catch (error) {
						console.log(error);
						toast.error(error);
					}
				}
			}
		}

535
536
537
		modelFileUrl = '';
		modelInputFile = '';
		modelTransferring = false;
538
539
		uploadProgress = null;

Timothy J. Baek's avatar
Timothy J. Baek committed
540
541
542
		models.set(await getModels());
	};

543
	const deleteModelHandler = async () => {
Timothy J. Baek's avatar
Timothy J. Baek committed
544
545
546
		const res = await deleteModel(localStorage.token, deleteModelTag).catch((error) => {
			toast.error(error);
		});
547

548
		if (res) {
Timothy J. Baek's avatar
Timothy J. Baek committed
549
			toast.success(`Deleted ${deleteModelTag}`);
550
551
552
		}

		deleteModelTag = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
553
		models.set(await getModels());
554
	};
Timothy J. Baek's avatar
Timothy J. Baek committed
555

556
	const getModels = async (type = 'all') => {
557
		const models = [];
558
		models.push(
559
			...(await getOllamaModels(localStorage.token).catch((error) => {
560
561
562
563
				toast.error(error);
				return [];
			}))
		);
Timothy J. Baek's avatar
Timothy J. Baek committed
564
565

		// If OpenAI API Key exists
566
567
568
569
570
		if (type === 'all' && OPENAI_API_KEY) {
			const openAIModels = await getOpenAIModels(localStorage.token).catch((error) => {
				console.log(error);
				return null;
			});
571

572
			models.push(...(openAIModels ? [{ name: 'hr' }, ...openAIModels] : []));
573
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
574
575

		return models;
576
577
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
578
	onMount(async () => {
579
580
581
		console.log('settings', $user.role === 'admin');
		if ($user.role === 'admin') {
			API_BASE_URL = await getOllamaAPIUrl(localStorage.token);
582
583
			OPENAI_API_BASE_URL = await getOpenAIUrl(localStorage.token);
			OPENAI_API_KEY = await getOpenAIKey(localStorage.token);
584
			promptSuggestions = $config?.default_prompt_suggestions;
585
586
		}

Timothy J. Baek's avatar
Timothy J. Baek committed
587
		let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
588
589
590
		console.log(settings);

		theme = localStorage.theme ?? 'dark';
Timothy J. Baek's avatar
Timothy J. Baek committed
591
592
		notificationEnabled = settings.notificationEnabled ?? false;

593
594
595
596
597
598
599
600
601
602
		system = settings.system ?? '';
		requestFormat = settings.requestFormat ?? '';

		options.seed = settings.seed ?? 0;
		options.temperature = settings.temperature ?? '';
		options.repeat_penalty = settings.repeat_penalty ?? '';
		options.top_k = settings.top_k ?? '';
		options.top_p = settings.top_p ?? '';
		options.num_ctx = settings.num_ctx ?? '';
		options = { ...options, ...settings.options };
Timothy J. Baek's avatar
Timothy J. Baek committed
603
		options.stop = (settings?.options?.stop ?? []).join(',');
604
605
606

		titleAutoGenerate = settings.titleAutoGenerate ?? true;
		speechAutoSend = settings.speechAutoSend ?? false;
Timothy J. Baek's avatar
Timothy J. Baek committed
607
		responseAutoCopy = settings.responseAutoCopy ?? false;
608
		titleAutoGenerateModel = settings.titleAutoGenerateModel ?? '';
609
		gravatarEmail = settings.gravatarEmail ?? '';
610
		speakVoice = settings.speakVoice ?? '';
611
612
613
614
615
616
617
618
619
620

		const getVoicesLoop = setInterval(async () => {
			const _voices = await speechSynthesis.getVoices();
			await voices.set(_voices);

			// do your loop
			if (_voices.length > 0) {
				clearInterval(getVoicesLoop);
			}
		}, 100);
621

622
623
		saveChatHistory = settings.saveChatHistory ?? true;

624
		ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => {
Timothy J. Baek's avatar
Timothy J. Baek committed
625
626
			return '';
		});
Timothy J. Baek's avatar
Timothy J. Baek committed
627
	});
Timothy J. Baek's avatar
Timothy J. Baek committed
628
629
630
</script>

<Modal bind:show>
Timothy J. Baek's avatar
Timothy J. Baek committed
631
	<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
632
		<div class=" flex justify-between dark:text-gray-300 px-5 py-4">
Timothy J. Baek's avatar
Timothy J. Baek committed
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
			<div class=" text-lg font-medium self-center">Settings</div>
			<button
				class="self-center"
				on:click={() => {
					show = false;
				}}
			>
				<svg
					xmlns="http://www.w3.org/2000/svg"
					viewBox="0 0 20 20"
					fill="currentColor"
					class="w-5 h-5"
				>
					<path
						d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
					/>
				</svg>
			</button>
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
652
		<hr class=" dark:border-gray-800" />
Timothy J. Baek's avatar
Timothy J. Baek committed
653

Timothy J. Baek's avatar
Timothy J. Baek committed
654
655
		<div class="flex flex-col md:flex-row w-full p-4 md:space-x-4">
			<div
Timothy J. Baek's avatar
Timothy J. Baek committed
656
				class="tabs flex flex-row overflow-x-auto space-x-1 md:space-x-0 md:space-y-1 md:flex-col flex-1 md:flex-none md:w-40 dark:text-gray-200 text-xs text-left mb-3 md:mb-0"
Timothy J. Baek's avatar
Timothy J. Baek committed
657
658
			>
				<button
659
					class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
Timothy J. Baek's avatar
Timothy J. Baek committed
660
					'general'
Timothy J. Baek's avatar
Timothy J. Baek committed
661
662
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
Timothy J. Baek's avatar
Timothy J. Baek committed
663
					on:click={() => {
664
						selectedTab = 'general';
Timothy J. Baek's avatar
Timothy J. Baek committed
665
					}}
Timothy J. Baek's avatar
Timothy J. Baek committed
666
				>
Timothy J. Baek's avatar
Timothy J. Baek committed
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
					<div class=" self-center mr-2">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 20 20"
							fill="currentColor"
							class="w-4 h-4"
						>
							<path
								fill-rule="evenodd"
								d="M8.34 1.804A1 1 0 019.32 1h1.36a1 1 0 01.98.804l.295 1.473c.497.144.971.342 1.416.587l1.25-.834a1 1 0 011.262.125l.962.962a1 1 0 01.125 1.262l-.834 1.25c.245.445.443.919.587 1.416l1.473.294a1 1 0 01.804.98v1.361a1 1 0 01-.804.98l-1.473.295a6.95 6.95 0 01-.587 1.416l.834 1.25a1 1 0 01-.125 1.262l-.962.962a1 1 0 01-1.262.125l-1.25-.834a6.953 6.953 0 01-1.416.587l-.294 1.473a1 1 0 01-.98.804H9.32a1 1 0 01-.98-.804l-.295-1.473a6.957 6.957 0 01-1.416-.587l-1.25.834a1 1 0 01-1.262-.125l-.962-.962a1 1 0 01-.125-1.262l.834-1.25a6.957 6.957 0 01-.587-1.416l-1.473-.294A1 1 0 011 10.68V9.32a1 1 0 01.804-.98l1.473-.295c.144-.497.342-.971.587-1.416l-.834-1.25a1 1 0 01.125-1.262l.962-.962A1 1 0 015.38 3.03l1.25.834a6.957 6.957 0 011.416-.587l.294-1.473zM13 10a3 3 0 11-6 0 3 3 0 016 0z"
								clip-rule="evenodd"
							/>
						</svg>
					</div>
					<div class=" self-center">General</div>
				</button>

Timothy J. Baek's avatar
Timothy J. Baek committed
684
				<button
685
686
					class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
					'advanced'
Timothy J. Baek's avatar
Timothy J. Baek committed
687
688
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
					on:click={() => {
						selectedTab = 'advanced';
					}}
				>
					<div class=" self-center mr-2">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 20 20"
							fill="currentColor"
							class="w-4 h-4"
						>
							<path
								d="M17 2.75a.75.75 0 00-1.5 0v5.5a.75.75 0 001.5 0v-5.5zM17 15.75a.75.75 0 00-1.5 0v1.5a.75.75 0 001.5 0v-1.5zM3.75 15a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5a.75.75 0 01.75-.75zM4.5 2.75a.75.75 0 00-1.5 0v5.5a.75.75 0 001.5 0v-5.5zM10 11a.75.75 0 01.75.75v5.5a.75.75 0 01-1.5 0v-5.5A.75.75 0 0110 11zM10.75 2.75a.75.75 0 00-1.5 0v1.5a.75.75 0 001.5 0v-1.5zM10 6a2 2 0 100 4 2 2 0 000-4zM3.75 10a2 2 0 100 4 2 2 0 000-4zM16.25 10a2 2 0 100 4 2 2 0 000-4z"
							/>
						</svg>
					</div>
					<div class=" self-center">Advanced</div>
				</button>

708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
				{#if $user?.role === 'admin'}
					<button
						class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
						'models'
							? 'bg-gray-200 dark:bg-gray-700'
							: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
						on:click={() => {
							selectedTab = 'models';
						}}
					>
						<div class=" self-center mr-2">
							<svg
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 20 20"
								fill="currentColor"
								class="w-4 h-4"
							>
								<path
									fill-rule="evenodd"
									d="M10 1c3.866 0 7 1.79 7 4s-3.134 4-7 4-7-1.79-7-4 3.134-4 7-4zm5.694 8.13c.464-.264.91-.583 1.306-.952V10c0 2.21-3.134 4-7 4s-7-1.79-7-4V8.178c.396.37.842.688 1.306.953C5.838 10.006 7.854 10.5 10 10.5s4.162-.494 5.694-1.37zM3 13.179V15c0 2.21 3.134 4 7 4s7-1.79 7-4v-1.822c-.396.37-.842.688-1.306.953-1.532.875-3.548 1.369-5.694 1.369s-4.162-.494-5.694-1.37A7.009 7.009 0 013 13.179z"
									clip-rule="evenodd"
								/>
							</svg>
						</div>
						<div class=" self-center">Models</div>
					</button>
734

735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
					<button
						class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
						'external'
							? 'bg-gray-200 dark:bg-gray-700'
							: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
						on:click={() => {
							selectedTab = 'external';
						}}
					>
						<div class=" self-center mr-2">
							<svg
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 16 16"
								fill="currentColor"
								class="w-4 h-4"
							>
								<path
									d="M1 9.5A3.5 3.5 0 0 0 4.5 13H12a3 3 0 0 0 .917-5.857 2.503 2.503 0 0 0-3.198-3.019 3.5 3.5 0 0 0-6.628 2.171A3.5 3.5 0 0 0 1 9.5Z"
								/>
							</svg>
						</div>
						<div class=" self-center">External</div>
					</button>
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783

					<button
						class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
						'interface'
							? 'bg-gray-200 dark:bg-gray-700'
							: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
						on:click={() => {
							selectedTab = 'interface';
						}}
					>
						<div class=" self-center mr-2">
							<svg
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 16 16"
								fill="currentColor"
								class="w-4 h-4"
							>
								<path
									fill-rule="evenodd"
									d="M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4Zm10.5 5.707a.5.5 0 0 0-.146-.353l-1-1a.5.5 0 0 0-.708 0L9.354 9.646a.5.5 0 0 1-.708 0L6.354 7.354a.5.5 0 0 0-.708 0l-2 2a.5.5 0 0 0-.146.353V12a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V9.707ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"
									clip-rule="evenodd"
								/>
							</svg>
						</div>
						<div class=" self-center">Interface</div>
					</button>
784
				{/if}
785

786
				<button
787
788
					class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
					'addons'
Timothy J. Baek's avatar
Timothy J. Baek committed
789
790
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
791
					on:click={() => {
792
						selectedTab = 'addons';
793
794
795
796
797
798
799
800
801
802
803
804
805
806
					}}
				>
					<div class=" self-center mr-2">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 20 20"
							fill="currentColor"
							class="w-4 h-4"
						>
							<path
								d="M12 4.467c0-.405.262-.75.559-1.027.276-.257.441-.584.441-.94 0-.828-.895-1.5-2-1.5s-2 .672-2 1.5c0 .362.171.694.456.953.29.265.544.6.544.994a.968.968 0 01-1.024.974 39.655 39.655 0 01-3.014-.306.75.75 0 00-.847.847c.14.993.242 1.999.306 3.014A.968.968 0 014.447 10c-.393 0-.729-.253-.994-.544C3.194 9.17 2.862 9 2.5 9 1.672 9 1 9.895 1 11s.672 2 1.5 2c.356 0 .683-.165.94-.441.276-.297.622-.559 1.027-.559a.997.997 0 011.004 1.03 39.747 39.747 0 01-.319 3.734.75.75 0 00.64.842c1.05.146 2.111.252 3.184.318A.97.97 0 0010 16.948c0-.394-.254-.73-.545-.995C9.171 15.693 9 15.362 9 15c0-.828.895-1.5 2-1.5s2 .672 2 1.5c0 .356-.165.683-.441.94-.297.276-.559.622-.559 1.027a.998.998 0 001.03 1.005c1.337-.05 2.659-.162 3.961-.337a.75.75 0 00.644-.644c.175-1.302.288-2.624.337-3.961A.998.998 0 0016.967 12c-.405 0-.75.262-1.027.559-.257.276-.584.441-.94.441-.828 0-1.5-.895-1.5-2s.672-2 1.5-2c.362 0 .694.17.953.455.265.291.601.545.995.545a.97.97 0 00.976-1.024 41.159 41.159 0 00-.318-3.184.75.75 0 00-.842-.64c-1.228.164-2.473.271-3.734.319A.997.997 0 0112 4.467z"
							/>
						</svg>
					</div>
807
					<div class=" self-center">Add-ons</div>
808
				</button>
Timothy J. Baek's avatar
Timothy J. Baek committed
809

810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
				<button
					class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
					'chats'
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
					on:click={() => {
						selectedTab = 'chats';
					}}
				>
					<div class=" self-center mr-2">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 16 16"
							fill="currentColor"
							class="w-4 h-4"
						>
							<path
								fill-rule="evenodd"
								d="M8 2C4.262 2 1 4.57 1 8c0 1.86.98 3.486 2.455 4.566a3.472 3.472 0 0 1-.469 1.26.75.75 0 0 0 .713 1.14 6.961 6.961 0 0 0 3.06-1.06c.403.062.818.094 1.241.094 3.738 0 7-2.57 7-6s-3.262-6-7-6ZM5 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm7-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM8 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
								clip-rule="evenodd"
							/>
						</svg>
					</div>
					<div class=" self-center">Chats</div>
				</button>

Timothy J. Baek's avatar
Timothy J. Baek committed
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
				<button
					class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
					'account'
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
					on:click={() => {
						selectedTab = 'account';
					}}
				>
					<div class=" self-center mr-2">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 16 16"
							fill="currentColor"
							class="w-4 h-4"
						>
							<path
								fill-rule="evenodd"
								d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0Zm-5-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0ZM8 9c-1.825 0-3.422.977-4.295 2.437A5.49 5.49 0 0 0 8 13.5a5.49 5.49 0 0 0 4.294-2.063A4.997 4.997 0 0 0 8 9Z"
								clip-rule="evenodd"
							/>
						</svg>
					</div>
					<div class=" self-center">Account</div>
				</button>

Timothy J. Baek's avatar
Timothy J. Baek committed
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
				<button
					class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
					'about'
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
					on:click={() => {
						selectedTab = 'about';
					}}
				>
					<div class=" self-center mr-2">
						<svg
							xmlns="http://www.w3.org/2000/svg"
							viewBox="0 0 20 20"
							fill="currentColor"
							class="w-4 h-4"
						>
							<path
								fill-rule="evenodd"
								d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z"
								clip-rule="evenodd"
							/>
						</svg>
					</div>
					<div class=" self-center">About</div>
				</button>
Timothy J. Baek's avatar
Timothy J. Baek committed
887
			</div>
888
			<div class="flex-1 md:min-h-[380px]">
889
				{#if selectedTab === 'general'}
Timothy J. Baek's avatar
Timothy J. Baek committed
890
					<div class="flex flex-col space-y-3">
Timothy J. Baek's avatar
Timothy J. Baek committed
891
						<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
892
893
894
895
							<div class=" mb-1 text-sm font-medium">WebUI Settings</div>

							<div class=" py-0.5 flex w-full justify-between">
								<div class=" self-center text-xs font-medium">Theme</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
896

Timothy J. Baek's avatar
Timothy J. Baek committed
897
								<!-- <button
Timothy J. Baek's avatar
Timothy J. Baek committed
898
899
900
901
902
									class="p-1 px-3 text-xs flex rounded transition"
									on:click={() => {
										toggleTheme();
									}}
								>
903

Timothy J. Baek's avatar
Timothy J. Baek committed
904
905
								</button> -->

906
907
								<div class="flex items-center relative">
									<div class=" absolute right-16">
Timothy J. Baek's avatar
Timothy J. Baek committed
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
										{#if theme === 'dark'}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 20 20"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													fill-rule="evenodd"
													d="M7.455 2.004a.75.75 0 01.26.77 7 7 0 009.958 7.967.75.75 0 011.067.853A8.5 8.5 0 116.647 1.921a.75.75 0 01.808.083z"
													clip-rule="evenodd"
												/>
											</svg>
										{:else if theme === 'light'}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 20 20"
												fill="currentColor"
												class="w-4 h-4 self-center"
											>
												<path
													d="M10 2a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 0110 2zM10 15a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 0110 15zM10 7a3 3 0 100 6 3 3 0 000-6zM15.657 5.404a.75.75 0 10-1.06-1.06l-1.061 1.06a.75.75 0 001.06 1.06l1.06-1.06zM6.464 14.596a.75.75 0 10-1.06-1.06l-1.06 1.06a.75.75 0 001.06 1.06l1.06-1.06zM18 10a.75.75 0 01-.75.75h-1.5a.75.75 0 010-1.5h1.5A.75.75 0 0118 10zM5 10a.75.75 0 01-.75.75h-1.5a.75.75 0 010-1.5h1.5A.75.75 0 015 10zM14.596 15.657a.75.75 0 001.06-1.06l-1.06-1.061a.75.75 0 10-1.06 1.06l1.06 1.06zM5.404 6.464a.75.75 0 001.06-1.06l-1.06-1.06a.75.75 0 10-1.061 1.06l1.06 1.06z"
												/>
											</svg>
										{/if}
									</div>

									<select
936
										class="w-fit pr-8 rounded py-2 px-2 text-xs bg-transparent outline-none text-right"
Timothy J. Baek's avatar
Timothy J. Baek committed
937
938
										bind:value={theme}
										placeholder="Select a theme"
939
										on:change={(e) => {
Timothy J. Baek's avatar
Timothy J. Baek committed
940
941
942
943
944
											localStorage.theme = theme;

											themes
												.filter((e) => e !== theme)
												.forEach((e) => {
945
946
947
													e.split(' ').forEach((e) => {
														document.documentElement.classList.remove(e);
													});
Timothy J. Baek's avatar
Timothy J. Baek committed
948
949
												});

950
951
952
											theme.split(' ').forEach((e) => {
												document.documentElement.classList.add(e);
											});
Timothy J. Baek's avatar
Timothy J. Baek committed
953
954
955
956
957
958

											console.log(theme);
										}}
									>
										<option value="dark">Dark</option>
										<option value="light">Light</option>
959
960
										<option value="rose-pine dark">Rosé Pine</option>
										<option value="rose-pine-dawn light">Rosé Pine Dawn</option>
Timothy J. Baek's avatar
Timothy J. Baek committed
961
962
									</select>
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
963
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983

							<div>
								<div class=" py-0.5 flex w-full justify-between">
									<div class=" self-center text-xs font-medium">Notification</div>

									<button
										class="p-1 px-3 text-xs flex rounded transition"
										on:click={() => {
											toggleNotification();
										}}
										type="button"
									>
										{#if notificationEnabled === true}
											<span class="ml-2 self-center">On</span>
										{:else}
											<span class="ml-2 self-center">Off</span>
										{/if}
									</button>
								</div>
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
984
985
						</div>

986
987
988
989
990
991
992
993
						{#if $user.role === 'admin'}
							<hr class=" dark:border-gray-700" />
							<div>
								<div class=" mb-2.5 text-sm font-medium">Ollama API URL</div>
								<div class="flex w-full">
									<div class="flex-1 mr-2">
										<input
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
Timothy J. Baek's avatar
Timothy J. Baek committed
994
											placeholder="Enter URL (e.g. http://localhost:11434/api)"
995
											bind:value={API_BASE_URL}
996
										/>
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
									</div>
									<button
										class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 rounded transition"
										on:click={() => {
											updateOllamaAPIUrlHandler();
										}}
									>
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 20 20"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												fill-rule="evenodd"
												d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z"
												clip-rule="evenodd"
											/>
										</svg>
									</button>
								</div>
1018

1019
								<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
Timothy J. Baek's avatar
Timothy J. Baek committed
1020
									Trouble accessing Ollama?
1021
									<a
Timothy J. Baek's avatar
Timothy J. Baek committed
1022
										class=" text-gray-300 font-medium"
1023
1024
1025
1026
1027
1028
										href="https://github.com/ollama-webui/ollama-webui#troubleshooting"
										target="_blank"
									>
										Click here for help.
									</a>
								</div>
1029
							</div>
1030
						{/if}
1031

Timothy J. Baek's avatar
Timothy J. Baek committed
1032
						<hr class=" dark:border-gray-700" />
1033

Timothy J. Baek's avatar
Timothy J. Baek committed
1034
						<div>
1035
1036
1037
							<div class=" mb-2.5 text-sm font-medium">System Prompt</div>
							<textarea
								bind:value={system}
Timothy J. Baek's avatar
Timothy J. Baek committed
1038
								class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
1039
								rows="4"
Timothy J. Baek's avatar
Timothy J. Baek committed
1040
1041
							/>
						</div>
1042

Timothy J. Baek's avatar
Timothy J. Baek committed
1043
1044
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
Timothy J. Baek's avatar
Timothy J. Baek committed
1045
								class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
Timothy J. Baek's avatar
Timothy J. Baek committed
1046
								on:click={() => {
1047
1048
1049
									saveSettings({
										system: system !== '' ? system : undefined
									});
Timothy J. Baek's avatar
Timothy J. Baek committed
1050
1051
1052
1053
1054
1055
1056
									show = false;
								}}
							>
								Save
							</button>
						</div>
					</div>
1057
				{:else if selectedTab === 'advanced'}
1058
					<div class="flex flex-col h-full justify-between text-sm">
1059
						<div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-80">
1060
							<div class=" text-sm font-medium">Parameters</div>
1061

1062
							<Advanced bind:options />
1063
1064
							<hr class=" dark:border-gray-700" />

1065
							<div>
1066
1067
1068
1069
1070
1071
								<div class=" py-1 flex w-full justify-between">
									<div class=" self-center text-sm font-medium">Request Mode</div>

									<button
										class="p-1 px-3 text-xs flex rounded transition"
										on:click={() => {
1072
											toggleRequestFormat();
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
										}}
									>
										{#if requestFormat === ''}
											<span class="ml-2 self-center"> Default </span>
										{:else if requestFormat === 'json'}
											<!-- <svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 20 20"
												fill="currentColor"
												class="w-4 h-4 self-center"
											>
												<path
													d="M10 2a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 0110 2zM10 15a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 0110 15zM10 7a3 3 0 100 6 3 3 0 000-6zM15.657 5.404a.75.75 0 10-1.06-1.06l-1.061 1.06a.75.75 0 001.06 1.06l1.06-1.06zM6.464 14.596a.75.75 0 10-1.06-1.06l-1.06 1.06a.75.75 0 001.06 1.06l1.06-1.06zM18 10a.75.75 0 01-.75.75h-1.5a.75.75 0 010-1.5h1.5A.75.75 0 0118 10zM5 10a.75.75 0 01-.75.75h-1.5a.75.75 0 010-1.5h1.5A.75.75 0 015 10zM14.596 15.657a.75.75 0 001.06-1.06l-1.06-1.061a.75.75 0 10-1.06 1.06l1.06 1.06zM5.404 6.464a.75.75 0 001.06-1.06l-1.06-1.06a.75.75 0 10-1.061 1.06l1.06 1.06z"
												/>
											</svg> -->
											<span class="ml-2 self-center"> JSON </span>
										{/if}
									</button>
								</div>
							</div>
1093
						</div>
1094

1095
1096
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
Timothy J. Baek's avatar
Timothy J. Baek committed
1097
								class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
1098
1099
								on:click={() => {
									saveSettings({
1100
1101
										options: {
											seed: (options.seed !== 0 ? options.seed : undefined) ?? undefined,
Timothy J. Baek's avatar
Timothy J. Baek committed
1102
1103
											stop:
												options.stop !== '' ? options.stop.split(',').filter((e) => e) : undefined,
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
											temperature: options.temperature !== '' ? options.temperature : undefined,
											repeat_penalty:
												options.repeat_penalty !== '' ? options.repeat_penalty : undefined,
											repeat_last_n:
												options.repeat_last_n !== '' ? options.repeat_last_n : undefined,
											mirostat: options.mirostat !== '' ? options.mirostat : undefined,
											mirostat_eta: options.mirostat_eta !== '' ? options.mirostat_eta : undefined,
											mirostat_tau: options.mirostat_tau !== '' ? options.mirostat_tau : undefined,
											top_k: options.top_k !== '' ? options.top_k : undefined,
											top_p: options.top_p !== '' ? options.top_p : undefined,
											tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
1115
1116
											num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined,
											num_predict: options.num_predict !== '' ? options.num_predict : undefined
1117
										}
1118
1119
1120
1121
1122
1123
1124
1125
									});
									show = false;
								}}
							>
								Save
							</button>
						</div>
					</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1126
				{:else if selectedTab === 'models'}
Timothy J. Baek's avatar
Timothy J. Baek committed
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
					<div class="flex flex-col h-full justify-between text-sm">
						<div class=" space-y-3 pr-1.5 overflow-y-scroll h-80">
							<div>
								<div class=" mb-2.5 text-sm font-medium">Pull a model from Ollama.ai</div>
								<div class="flex w-full">
									<div class="flex-1 mr-2">
										<input
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
											placeholder="Enter model tag (e.g. mistral:7b)"
											bind:value={modelTag}
										/>
									</div>
									<button
1140
										class="px-3 text-gray-100 bg-emerald-600 hover:bg-emerald-700 disabled:bg-gray-700 disabled:cursor-not-allowed rounded transition"
Timothy J. Baek's avatar
Timothy J. Baek committed
1141
1142
1143
										on:click={() => {
											pullModelHandler();
										}}
1144
										disabled={modelTransferring}
Timothy J. Baek's avatar
Timothy J. Baek committed
1145
									>
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
										{#if modelTransferring}
											<div class="self-center">
												<svg
													class=" w-4 h-4"
													viewBox="0 0 24 24"
													fill="currentColor"
													xmlns="http://www.w3.org/2000/svg"
													><style>
														.spinner_ajPY {
															transform-origin: center;
															animation: spinner_AtaB 0.75s infinite linear;
														}
														@keyframes spinner_AtaB {
															100% {
																transform: rotate(360deg);
															}
														}
													</style><path
														d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
														opacity=".25"
													/><path
														d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
														class="spinner_ajPY"
													/></svg
												>
											</div>
										{:else}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 16 16"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
												/>
												<path
													d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
												/>
											</svg>
										{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1187
									</button>
Timothy J. Baek's avatar
Timothy J. Baek committed
1188
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1189

Timothy J. Baek's avatar
Timothy J. Baek committed
1190
								<div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
Timothy J. Baek's avatar
Timothy J. Baek committed
1191
1192
1193
1194
									To access the available model names for downloading, <a
										class=" text-gray-500 dark:text-gray-300 font-medium"
										href="https://ollama.ai/library"
										target="_blank">click here.</a
Timothy J. Baek's avatar
Timothy J. Baek committed
1195
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
1196
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1197

Timothy J. Baek's avatar
Timothy J. Baek committed
1198
								{#if Object.keys(modelDownloadStatus).length > 0}
1199
									{#each Object.keys(modelDownloadStatus) as model}
Timothy J. Baek's avatar
Timothy J. Baek committed
1200
										<div class="flex flex-col">
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
1201
											<div class="font-medium mb-1">{model}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1202
1203
1204
											<div class="">
												<div
													class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
1205
1206
1207
1208
													style="width: {Math.max(
														15,
														modelDownloadStatus[model].pullProgress ?? 0
													)}%"
Timothy J. Baek's avatar
Timothy J. Baek committed
1209
												>
1210
													{modelDownloadStatus[model].pullProgress ?? 0}%
Timothy J. Baek's avatar
Timothy J. Baek committed
1211
1212
												</div>
												<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
1213
													{modelDownloadStatus[model].digest}
Timothy J. Baek's avatar
Timothy J. Baek committed
1214
												</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1215
1216
											</div>
										</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1217
									{/each}
Timothy J. Baek's avatar
Timothy J. Baek committed
1218
								{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1219
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1220

Timothy J. Baek's avatar
Timothy J. Baek committed
1221
1222
							<hr class=" dark:border-gray-700" />

1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
							<div>
								<div class=" mb-2.5 text-sm font-medium">Delete a model</div>
								<div class="flex w-full">
									<div class="flex-1 mr-2">
										<select
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
											bind:value={deleteModelTag}
											placeholder="Select a model"
										>
											{#if !deleteModelTag}
												<option value="" disabled selected>Select a model</option>
											{/if}
											{#each $models.filter((m) => m.size != null) as model}
												<option value={model.name} class="bg-gray-100 dark:bg-gray-700"
													>{model.name +
														' (' +
														(model.size / 1024 ** 3).toFixed(1) +
														' GB)'}</option
												>
											{/each}
										</select>
									</div>
									<button
										class="px-3 bg-red-700 hover:bg-red-800 text-gray-100 rounded transition"
										on:click={() => {
											deleteModelHandler();
										}}
									>
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												fill-rule="evenodd"
												d="M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z"
												clip-rule="evenodd"
											/>
										</svg>
									</button>
								</div>
							</div>

							<hr class=" dark:border-gray-700" />

1269
1270
1271
1272
1273
1274
							<form
								on:submit|preventDefault={() => {
									uploadModelHandler();
								}}
							>
								<div class=" mb-2 flex w-full justify-between">
1275
1276
1277
1278
1279
1280
1281
									<div class="  text-sm font-medium">
										Upload a GGUF model <a
											class=" text-xs font-medium text-gray-500 underline"
											href="https://github.com/jmorganca/ollama/blob/main/README.md#import-from-gguf"
											target="_blank">(Experimental)</a
										>
									</div>
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301

									<button
										class="p-1 px-3 text-xs flex rounded transition"
										on:click={() => {
											if (modelUploadMode === 'file') {
												modelUploadMode = 'url';
											} else {
												modelUploadMode = 'file';
											}
										}}
										type="button"
									>
										{#if modelUploadMode === 'file'}
											<span class="ml-2 self-center">File Mode</span>
										{:else}
											<span class="ml-2 self-center">URL Mode</span>
										{/if}
									</button>
								</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
1302
								<div class="flex w-full mb-1.5">
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
									<div class="flex flex-col w-full">
										{#if modelUploadMode === 'file'}
											<div
												class="flex-1 {modelInputFile && modelInputFile.length > 0 ? 'mr-2' : ''}"
											>
												<input
													id="model-upload-input"
													type="file"
													bind:files={modelInputFile}
													on:change={() => {
														console.log(modelInputFile);
													}}
													accept=".gguf"
													required
													hidden
												/>
Timothy J. Baek's avatar
Timothy J. Baek committed
1319

1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
												<button
													type="button"
													class="w-full rounded text-left py-2 px-4 dark:text-gray-300 dark:bg-gray-800"
													on:click={() => {
														document.getElementById('model-upload-input').click();
													}}
												>
													{#if modelInputFile && modelInputFile.length > 0}
														{modelInputFile[0].name}
													{:else}
														Click here to select
													{/if}
												</button>
											</div>
										{:else}
											<div class="flex-1 {modelFileUrl !== '' ? 'mr-2' : ''}">
												<input
													class="w-full rounded text-left py-2 px-4 dark:text-gray-300 dark:bg-gray-800 outline-none {modelFileUrl !==
													''
														? 'mr-2'
														: ''}"
													type="url"
													required
													bind:value={modelFileUrl}
													placeholder="Type HuggingFace Resolve (Download) URL"
												/>
											</div>
										{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1348
									</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1349

1350
									{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
Timothy J. Baek's avatar
Timothy J. Baek committed
1351
										<button
1352
1353
1354
											class="px-3 text-gray-100 bg-emerald-600 hover:bg-emerald-700 disabled:bg-gray-700 disabled:cursor-not-allowed rounded transition"
											type="submit"
											disabled={modelTransferring}
Timothy J. Baek's avatar
Timothy J. Baek committed
1355
										>
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
											{#if modelTransferring}
												<div class="self-center">
													<svg
														class=" w-4 h-4"
														viewBox="0 0 24 24"
														fill="currentColor"
														xmlns="http://www.w3.org/2000/svg"
														><style>
															.spinner_ajPY {
																transform-origin: center;
																animation: spinner_AtaB 0.75s infinite linear;
															}
															@keyframes spinner_AtaB {
																100% {
																	transform: rotate(360deg);
																}
															}
														</style><path
															d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
															opacity=".25"
														/><path
															d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
															class="spinner_ajPY"
														/></svg
													>
												</div>
											{:else}
												<svg
													xmlns="http://www.w3.org/2000/svg"
													viewBox="0 0 16 16"
													fill="currentColor"
													class="w-4 h-4"
												>
													<path
														d="M7.25 10.25a.75.75 0 0 0 1.5 0V4.56l2.22 2.22a.75.75 0 1 0 1.06-1.06l-3.5-3.5a.75.75 0 0 0-1.06 0l-3.5 3.5a.75.75 0 0 0 1.06 1.06l2.22-2.22v5.69Z"
													/>
													<path
														d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
													/>
												</svg>
											{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1397
1398
										</button>
									{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1399
1400
								</div>

1401
								{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
Timothy J. Baek's avatar
Timothy J. Baek committed
1402
1403
1404
1405
1406
1407
									<div>
										<div>
											<div class=" my-2.5 text-sm font-medium">Modelfile Content</div>
											<textarea
												bind:value={modelFileContent}
												class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
Timothy J. Baek's avatar
Timothy J. Baek committed
1408
												rows="6"
Timothy J. Baek's avatar
Timothy J. Baek committed
1409
1410
1411
1412
1413
1414
1415
1416
1417
											/>
										</div>
									</div>
								{/if}
								<div class=" mt-1 text-xs text-gray-400 dark:text-gray-500">
									To access the GGUF models available for downloading, <a
										class=" text-gray-500 dark:text-gray-300 font-medium"
										href="https://huggingface.co/models?search=gguf"
										target="_blank">click here.</a
1418
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
1419
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1420

1421
								{#if uploadProgress !== null}
Timothy J. Baek's avatar
Timothy J. Baek committed
1422
									<div class="mt-2">
1423
										<div class=" mb-2 text-xs">Upload Progress</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1424

Timothy J. Baek's avatar
Timothy J. Baek committed
1425
1426
										<div class="w-full rounded-full dark:bg-gray-800">
											<div
Timothy J. Baek's avatar
Timothy J. Baek committed
1427
												class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
1428
												style="width: {Math.max(15, uploadProgress ?? 0)}%"
Timothy J. Baek's avatar
Timothy J. Baek committed
1429
											>
1430
												{uploadProgress ?? 0}%
Timothy J. Baek's avatar
Timothy J. Baek committed
1431
1432
1433
											</div>
										</div>
										<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
1434
											{modelFileDigest}
Timothy J. Baek's avatar
Timothy J. Baek committed
1435
1436
1437
										</div>
									</div>
								{/if}
1438
							</form>
Timothy J. Baek's avatar
Timothy J. Baek committed
1439
1440
						</div>
					</div>
1441
1442
1443
1444
				{:else if selectedTab === 'external'}
					<form
						class="flex flex-col h-full justify-between space-y-3 text-sm"
						on:submit|preventDefault={() => {
1445
1446
1447
1448
1449
1450
							updateOpenAIHandler();

							// saveSettings({
							// 	OPENAI_API_KEY: OPENAI_API_KEY !== '' ? OPENAI_API_KEY : undefined,
							// 	OPENAI_API_BASE_URL: OPENAI_API_BASE_URL !== '' ? OPENAI_API_BASE_URL : undefined
							// });
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
							show = false;
						}}
					>
						<div class=" space-y-3">
							<div>
								<div class=" mb-2.5 text-sm font-medium">OpenAI API Key</div>
								<div class="flex w-full">
									<div class="flex-1">
										<input
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
											placeholder="Enter OpenAI API Key"
											bind:value={OPENAI_API_KEY}
											autocomplete="off"
										/>
									</div>
								</div>
								<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
									Adds optional support for online models.
								</div>
							</div>

							<hr class=" dark:border-gray-700" />

							<div>
								<div class=" mb-2.5 text-sm font-medium">OpenAI API Base URL</div>
								<div class="flex w-full">
									<div class="flex-1">
										<input
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
											placeholder="Enter OpenAI API Key"
											bind:value={OPENAI_API_BASE_URL}
											autocomplete="off"
										/>
									</div>
								</div>
								<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
									WebUI will make requests to <span class=" text-gray-200"
										>'{OPENAI_API_BASE_URL}/chat'</span
									>
								</div>
							</div>
						</div>

1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
								class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
								type="submit"
							>
								Save
							</button>
						</div>
					</form>
				{:else if selectedTab === 'interface'}
					<form
						class="flex flex-col h-full justify-between space-y-3 text-sm"
						on:submit|preventDefault={() => {
							updateInterfaceHandler();
							show = false;
						}}
					>
						<div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-80">
							<div class="flex w-full justify-between mb-2">
								<div class=" self-center text-sm font-semibold">Default Prompt Suggestions</div>

								<button
									class="p-1 px-3 text-xs flex rounded transition"
									type="button"
									on:click={() => {
										if (promptSuggestions.length === 0 || promptSuggestions.at(-1).content !== '') {
											promptSuggestions = [...promptSuggestions, { content: '', title: ['', ''] }];
										}
									}}
								>
									<svg
										xmlns="http://www.w3.org/2000/svg"
										viewBox="0 0 20 20"
										fill="currentColor"
										class="w-4 h-4"
									>
										<path
											d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
										/>
									</svg>
								</button>
							</div>
							<div class="flex flex-col space-y-1">
								{#each promptSuggestions as prompt, promptIdx}
									<div class=" flex border dark:border-gray-600 rounded-lg">
										<div class="flex flex-col flex-1">
											<div class="flex border-b dark:border-gray-600 w-full">
												<input
													class="px-3 py-1.5 text-xs w-full bg-transparent outline-none border-r dark:border-gray-600"
													placeholder="Title (e.g. Tell me a fun fact)"
													bind:value={prompt.title[0]}
												/>

												<input
													class="px-3 py-1.5 text-xs w-full bg-transparent outline-none border-r dark:border-gray-600"
													placeholder="Subtitle (e.g. about the Roman Empire)"
													bind:value={prompt.title[1]}
												/>
											</div>

											<input
												class="px-3 py-1.5 text-xs w-full bg-transparent outline-none border-r dark:border-gray-600"
												placeholder="Prompt (e.g. Tell me a fun fact about the Roman Empire)"
												bind:value={prompt.content}
											/>
										</div>

										<button
											class="px-2"
											type="button"
											on:click={() => {
												promptSuggestions.splice(promptIdx, 1);
												promptSuggestions = promptSuggestions;
											}}
										>
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 20 20"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
												/>
											</svg>
										</button>
									</div>
								{/each}
							</div>

							{#if promptSuggestions.length > 0}
								<div class="text-xs text-left w-full mt-2">
									Adjusting these settings will apply changes universally to all users.
								</div>
							{/if}
						</div>

1591
1592
1593
1594
1595
1596
1597
1598
1599
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
								class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
								type="submit"
							>
								Save
							</button>
						</div>
					</form>
1600
				{:else if selectedTab === 'addons'}
Timothy J. Baek's avatar
Timothy J. Baek committed
1601
1602
1603
					<form
						class="flex flex-col h-full justify-between space-y-3 text-sm"
						on:submit|preventDefault={() => {
1604
1605
1606
							saveSettings({
								speakVoice: speakVoice !== '' ? speakVoice : undefined
							});
Timothy J. Baek's avatar
Timothy J. Baek committed
1607
1608
1609
							show = false;
						}}
					>
1610
						<div class=" space-y-3">
1611
							<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1612
1613
1614
1615
								<div class=" mb-1 text-sm font-medium">WebUI Add-ons</div>

								<div>
									<div class=" py-0.5 flex w-full justify-between">
1616
										<div class=" self-center text-xs font-medium">Title Auto-Generation</div>
1617

Timothy J. Baek's avatar
Timothy J. Baek committed
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
										<button
											class="p-1 px-3 text-xs flex rounded transition"
											on:click={() => {
												toggleTitleAutoGenerate();
											}}
											type="button"
										>
											{#if titleAutoGenerate === true}
												<span class="ml-2 self-center">On</span>
											{:else}
												<span class="ml-2 self-center">Off</span>
											{/if}
										</button>
									</div>
								</div>
1633

Timothy J. Baek's avatar
Timothy J. Baek committed
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
								<div>
									<div class=" py-0.5 flex w-full justify-between">
										<div class=" self-center text-xs font-medium">Voice Input Auto-Send</div>

										<button
											class="p-1 px-3 text-xs flex rounded transition"
											on:click={() => {
												toggleSpeechAutoSend();
											}}
											type="button"
										>
											{#if speechAutoSend === true}
												<span class="ml-2 self-center">On</span>
											{:else}
												<span class="ml-2 self-center">Off</span>
											{/if}
										</button>
									</div>
1652
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674

								<div>
									<div class=" py-0.5 flex w-full justify-between">
										<div class=" self-center text-xs font-medium">
											Response AutoCopy to Clipboard
										</div>

										<button
											class="p-1 px-3 text-xs flex rounded transition"
											on:click={() => {
												toggleResponseAutoCopy();
											}}
											type="button"
										>
											{#if responseAutoCopy === true}
												<span class="ml-2 self-center">On</span>
											{:else}
												<span class="ml-2 self-center">Off</span>
											{/if}
										</button>
									</div>
								</div>
1675
1676
1677
							</div>

							<hr class=" dark:border-gray-700" />
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687

							<div>
								<div class=" mb-2.5 text-sm font-medium">Set Title Auto-Generation Model</div>
								<div class="flex w-full">
									<div class="flex-1 mr-2">
										<select
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
											bind:value={titleAutoGenerateModel}
											placeholder="Select a model"
										>
1688
											<option value="" selected>Current Model</option>
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
											{#each $models.filter((m) => m.size != null) as model}
												<option value={model.name} class="bg-gray-100 dark:bg-gray-700"
													>{model.name +
														' (' +
														(model.size / 1024 ** 3).toFixed(1) +
														' GB)'}</option
												>
											{/each}
										</select>
									</div>
									<button
										class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-800 dark:text-gray-100 rounded transition"
										on:click={() => {
											saveSettings({
												titleAutoGenerateModel:
													titleAutoGenerateModel !== '' ? titleAutoGenerateModel : undefined
											});
										}}
										type="button"
									>
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-3.5 h-3.5"
										>
											<path
												fill-rule="evenodd"
												d="M13.836 2.477a.75.75 0 0 1 .75.75v3.182a.75.75 0 0 1-.75.75h-3.182a.75.75 0 0 1 0-1.5h1.37l-.84-.841a4.5 4.5 0 0 0-7.08.932.75.75 0 0 1-1.3-.75 6 6 0 0 1 9.44-1.242l.842.84V3.227a.75.75 0 0 1 .75-.75Zm-.911 7.5A.75.75 0 0 1 13.199 11a6 6 0 0 1-9.44 1.241l-.84-.84v1.371a.75.75 0 0 1-1.5 0V9.591a.75.75 0 0 1 .75-.75H5.35a.75.75 0 0 1 0 1.5H3.98l.841.841a4.5 4.5 0 0 0 7.08-.932.75.75 0 0 1 1.025-.273Z"
												clip-rule="evenodd"
											/>
										</svg>
									</button>
								</div>
							</div>

1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
							<hr class=" dark:border-gray-700" />

							<div class=" space-y-3">
								<div>
									<div class=" mb-2.5 text-sm font-medium">Set Default Voice</div>
									<div class="flex w-full">
										<div class="flex-1">
											<select
												class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
												bind:value={speakVoice}
												placeholder="Select a voice"
											>
												<option value="" selected>Default</option>
												{#each $voices.filter((v) => v.localService === true) as voice}
													<option value={voice.name} class="bg-gray-100 dark:bg-gray-700"
														>{voice.name}</option
													>
												{/each}
											</select>
										</div>
									</div>
								</div>
							</div>

Xiaodong Ye's avatar
Xiaodong Ye committed
1749
							<!--
Timothy J. Baek's avatar
Timothy J. Baek committed
1750
1751
1752
1753
1754
1755
1756
							<div>
								<div class=" mb-2.5 text-sm font-medium">
									Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>
								</div>
								<div class="flex w-full">
									<div class="flex-1">
										<input
Timothy J. Baek's avatar
Timothy J. Baek committed
1757
											class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
Timothy J. Baek's avatar
Timothy J. Baek committed
1758
1759
1760
1761
1762
1763
1764
											placeholder="Enter Your Email"
											bind:value={gravatarEmail}
											autocomplete="off"
											type="email"
										/>
									</div>
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1765
								<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
Timothy J. Baek's avatar
Timothy J. Baek committed
1766
									Changes user profile image to match your <a
Timothy J. Baek's avatar
Timothy J. Baek committed
1767
										class=" text-gray-500 dark:text-gray-300 font-medium"
Timothy J. Baek's avatar
Timothy J. Baek committed
1768
1769
1770
1771
										href="https://gravatar.com/"
										target="_blank">Gravatar.</a
									>
								</div>
1772
							</div> -->
1773
1774
						</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
1775
1776
1777
1778
1779
1780
1781
1782
1783
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
								class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
								type="submit"
							>
								Save
							</button>
						</div>
					</form>
1784
1785
				{:else if selectedTab === 'chats'}
					<div class="flex flex-col h-full justify-between space-y-3 text-sm">
Timothy J. Baek's avatar
Timothy J. Baek committed
1786
						<div class=" space-y-2">
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
							<div
								class="flex flex-col justify-between rounded-md items-center py-2 px-3.5 w-full transition"
							>
								<div class="flex w-full justify-between">
									<div class=" self-center text-sm font-medium">Chat History</div>

									<button
										class="p-1 px-3 text-xs flex rounded transition"
										type="button"
										on:click={() => {
											toggleSaveChatHistory();
										}}
									>
										{#if saveChatHistory === true}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 16 16"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" />
												<path
													fill-rule="evenodd"
													d="M1.38 8.28a.87.87 0 0 1 0-.566 7.003 7.003 0 0 1 13.238.006.87.87 0 0 1 0 .566A7.003 7.003 0 0 1 1.379 8.28ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
													clip-rule="evenodd"
												/>
											</svg>

											<span class="ml-2 self-center"> On </span>
										{:else}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 16 16"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													fill-rule="evenodd"
													d="M3.28 2.22a.75.75 0 0 0-1.06 1.06l10.5 10.5a.75.75 0 1 0 1.06-1.06l-1.322-1.323a7.012 7.012 0 0 0 2.16-3.11.87.87 0 0 0 0-.567A7.003 7.003 0 0 0 4.82 3.76l-1.54-1.54Zm3.196 3.195 1.135 1.136A1.502 1.502 0 0 1 9.45 8.389l1.136 1.135a3 3 0 0 0-4.109-4.109Z"
													clip-rule="evenodd"
												/>
												<path
													d="m7.812 10.994 1.816 1.816A7.003 7.003 0 0 1 1.38 8.28a.87.87 0 0 1 0-.566 6.985 6.985 0 0 1 1.113-2.039l2.513 2.513a3 3 0 0 0 2.806 2.806Z"
												/>
											</svg>

											<span class="ml-2 self-center">Off</span>
										{/if}
									</button>
								</div>

								<div class="text-xs text-left w-full font-medium mt-0.5">
									This setting does not sync across browsers or devices.
								</div>
							</div>

							<hr class=" dark:border-gray-700" />

Timothy J. Baek's avatar
Timothy J. Baek committed
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
							<div class="flex flex-col">
								<input
									id="chat-import-input"
									bind:files={importFiles}
									type="file"
									accept=".json"
									hidden
								/>
								<button
									class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
									on:click={() => {
										document.getElementById('chat-import-input').click();
									}}
								>
									<div class=" self-center mr-3">
1860
1861
										<svg
											xmlns="http://www.w3.org/2000/svg"
Timothy J. Baek's avatar
Timothy J. Baek committed
1862
											viewBox="0 0 16 16"
1863
1864
1865
1866
1867
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												fill-rule="evenodd"
Timothy J. Baek's avatar
Timothy J. Baek committed
1868
												d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 9.5a.75.75 0 0 1-.75-.75V8.06l-.72.72a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-.72-.72v2.69a.75.75 0 0 1-.75.75Z"
1869
1870
1871
												clip-rule="evenodd"
											/>
										</svg>
Timothy J. Baek's avatar
Timothy J. Baek committed
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
									</div>
									<div class=" self-center text-sm font-medium">Import Chats</div>
								</button>
								<button
									class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
									on:click={() => {
										exportChats();
									}}
								>
									<div class=" self-center mr-3">
1882
1883
										<svg
											xmlns="http://www.w3.org/2000/svg"
Timothy J. Baek's avatar
Timothy J. Baek committed
1884
											viewBox="0 0 16 16"
1885
1886
1887
1888
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
Timothy J. Baek's avatar
Timothy J. Baek committed
1889
1890
1891
												fill-rule="evenodd"
												d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
												clip-rule="evenodd"
1892
1893
											/>
										</svg>
Timothy J. Baek's avatar
Timothy J. Baek committed
1894
1895
1896
									</div>
									<div class=" self-center text-sm font-medium">Export Chats</div>
								</button>
1897
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962

							<hr class=" dark:border-gray-700" />

							{#if showDeleteConfirm}
								<div
									class="flex justify-between rounded-md items-center py-2 px-3.5 w-full transition"
								>
									<div class="flex items-center space-x-3">
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												d="M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3Z"
											/>
											<path
												fill-rule="evenodd"
												d="M13 6H3v6a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V6ZM5.72 7.47a.75.75 0 0 1 1.06 0L8 8.69l1.22-1.22a.75.75 0 1 1 1.06 1.06L9.06 9.75l1.22 1.22a.75.75 0 1 1-1.06 1.06L8 10.81l-1.22 1.22a.75.75 0 0 1-1.06-1.06l1.22-1.22-1.22-1.22a.75.75 0 0 1 0-1.06Z"
												clip-rule="evenodd"
											/>
										</svg>
										<span>Are you sure?</span>
									</div>

									<div class="flex space-x-1.5 items-center">
										<button
											class="hover:text-white transition"
											on:click={() => {
												deleteChats();
												showDeleteConfirm = false;
											}}
										>
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 20 20"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													fill-rule="evenodd"
													d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
													clip-rule="evenodd"
												/>
											</svg>
										</button>
										<button
											class="hover:text-white transition"
											on:click={() => {
												showDeleteConfirm = false;
											}}
										>
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 20 20"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
												/>
											</svg>
										</button>
									</div>
1963
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1964
1965
1966
1967
1968
1969
							{:else}
								<button
									class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
									on:click={() => {
										showDeleteConfirm = true;
									}}
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
								>
									<div class=" self-center mr-3">
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												fill-rule="evenodd"
												d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm7 7a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h4.5A.75.75 0 0 1 11 9Z"
												clip-rule="evenodd"
											/>
										</svg>
									</div>
									<div class=" self-center text-sm font-medium">Delete Chats</div>
								</button>
							{/if}

							{#if $user?.role === 'admin'}
								<hr class=" dark:border-gray-700" />

								<button
									class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
									on:click={() => {
										exportAllUserChats();
									}}
Timothy J. Baek's avatar
Timothy J. Baek committed
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
								>
									<div class=" self-center mr-3">
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												d="M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3Z"
											/>
											<path
												fill-rule="evenodd"
2010
												d="M13 6H3v6a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V6ZM8.75 7.75a.75.75 0 0 0-1.5 0v2.69L6.03 9.22a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l2.5-2.5a.75.75 0 1 0-1.06-1.06l-1.22 1.22V7.75Z"
Timothy J. Baek's avatar
Timothy J. Baek committed
2011
2012
2013
2014
												clip-rule="evenodd"
											/>
										</svg>
									</div>
2015
									<div class=" self-center text-sm font-medium">Export All Chats (All Users)</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
2016
								</button>
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049

								<hr class=" dark:border-gray-700" />

								<button
									class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
									on:click={() => {
										const res = resetVectorDB(localStorage.token).catch((error) => {
											toast.error(error);
											return null;
										});

										if (res) {
											toast.success('Success');
										}
									}}
								>
									<div class=" self-center mr-3">
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												fill-rule="evenodd"
												d="M3.5 2A1.5 1.5 0 0 0 2 3.5v9A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 12.5 4H9.621a1.5 1.5 0 0 1-1.06-.44L7.439 2.44A1.5 1.5 0 0 0 6.38 2H3.5Zm6.75 7.75a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0 0 1.5h4.5Z"
												clip-rule="evenodd"
											/>
										</svg>
									</div>
									<div class=" self-center text-sm font-medium">Reset Vector Storage</div>
								</button>
							{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
2050
						</div>
2051
					</div>
2052
				{:else if selectedTab === 'account'}
2053
2054
2055
					<Account
						saveHandler={() => {
							show = false;
2056
						}}
2057
					/>
Timothy J. Baek's avatar
Timothy J. Baek committed
2058
				{:else if selectedTab === 'about'}
Timothy J. Baek's avatar
Timothy J. Baek committed
2059
					<div class="flex flex-col h-full justify-between space-y-3 text-sm mb-6">
Timothy J. Baek's avatar
Timothy J. Baek committed
2060
2061
2062
2063
						<div class=" space-y-3">
							<div>
								<div class=" mb-2.5 text-sm font-medium">Ollama Web UI Version</div>
								<div class="flex w-full">
Timothy J. Baek's avatar
Timothy J. Baek committed
2064
									<div class="flex-1 text-xs text-gray-700 dark:text-gray-200">
2065
										{$config && $config.version ? $config.version : WEB_UI_VERSION}
Timothy J. Baek's avatar
Timothy J. Baek committed
2066
									</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
2067
2068
2069
2070
2071
								</div>
							</div>

							<hr class=" dark:border-gray-700" />

Timothy J. Baek's avatar
Timothy J. Baek committed
2072
2073
2074
2075
							<div>
								<div class=" mb-2.5 text-sm font-medium">Ollama Version</div>
								<div class="flex w-full">
									<div class="flex-1 text-xs text-gray-700 dark:text-gray-200">
Timothy J. Baek's avatar
Timothy J. Baek committed
2076
										{ollamaVersion ?? 'N/A'}
Timothy J. Baek's avatar
Timothy J. Baek committed
2077
2078
2079
2080
2081
2082
									</div>
								</div>
							</div>

							<hr class=" dark:border-gray-700" />

2083
2084
2085
2086
2087
2088
2089
							<div class="flex space-x-1">
								<a href="https://discord.gg/5rJgQTnV4s" target="_blank">
									<img
										alt="Discord"
										src="https://img.shields.io/badge/Discord-Ollama_Web_UI-blue?logo=discord&logoColor=white"
									/>
								</a>
Timothy J. Baek's avatar
Timothy J. Baek committed
2090

2091
								<a href="https://github.com/ollama-webui/ollama-webui" target="_blank">
2092
									<img
2093
										alt="Github Repo"
2094
2095
2096
										src="https://img.shields.io/github/stars/ollama-webui/ollama-webui?style=social&label=Star us on Github"
									/>
								</a>
Timothy J. Baek's avatar
Timothy J. Baek committed
2097
							</div>
2098
2099
2100
2101
2102
2103
2104
2105

							<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
								Created by <a
									class=" text-gray-500 dark:text-gray-300 font-medium"
									href="https://github.com/tjbck"
									target="_blank">Timothy J. Baek</a
								>
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
2106
2107
						</div>
					</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
2108
2109
				{/if}
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
2110
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
2111
2112
	</div>
</Modal>
2113
2114
2115
2116
2117
2118
2119
2120
2121

<style>
	input::-webkit-outer-spin-button,
	input::-webkit-inner-spin-button {
		/* display: none; <- Crashes Chrome on hover */
		-webkit-appearance: none;
		margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
	}

2122
2123
2124
2125
2126
2127
2128
2129
2130
	.tabs::-webkit-scrollbar {
		display: none; /* for Chrome, Safari and Opera */
	}

	.tabs {
		-ms-overflow-style: none; /* IE and Edge */
		scrollbar-width: none; /* Firefox */
	}

2131
2132
2133
2134
	input[type='number'] {
		-moz-appearance: textfield; /* Firefox */
	}
</style>