SettingsModal.svelte 53 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 Modal from '../common/Modal.svelte';
3

Timothy J. Baek's avatar
Timothy J. Baek committed
4
5
6
7
8
9
	import {
		WEB_UI_VERSION,
		OLLAMA_API_BASE_URL,
		WEBUI_API_BASE_URL,
		WEBUI_BASE_URL
	} from '$lib/constants';
10
	import toast from 'svelte-french-toast';
Timothy J. Baek's avatar
Timothy J. Baek committed
11
	import { onMount } from 'svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
12
	import { config, models, settings, user } from '$lib/stores';
13
	import { splitStream, getGravatarURL } from '$lib/utils';
14
	import Advanced from './Settings/Advanced.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
15
	import { stringify } from 'postcss';
Timothy J. Baek's avatar
Timothy J. Baek committed
16
	import { getOllamaVersion } from '$lib/apis/ollama';
17

Timothy J. Baek's avatar
Timothy J. Baek committed
18
	export let show = false;
19
20
21
22

	const saveSettings = async (updated) => {
		console.log(updated);
		await settings.set({ ...$settings, ...updated });
23
		await models.set(await getModels());
24
25
		localStorage.setItem('settings', JSON.stringify($settings));
	};
26

27
28
29
	let selectedTab = 'general';

	// General
Timothy J. Baek's avatar
Timothy J. Baek committed
30
	let API_BASE_URL = OLLAMA_API_BASE_URL;
Timothy J. Baek's avatar
Timothy J. Baek committed
31
	let theme = 'dark';
Timothy J. Baek's avatar
Timothy J. Baek committed
32
	let notificationEnabled = false;
33
	let system = '';
34
35

	// Advanced
36
	let requestFormat = '';
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	let options = {
		// Advanced
		seed: 0,
		temperature: '',
		repeat_penalty: '',
		repeat_last_n: '',
		mirostat: '',
		mirostat_eta: '',
		mirostat_tau: '',
		top_k: '',
		top_p: '',
		stop: '',
		tfs_z: '',
		num_ctx: ''
	};
52

53
	// Models
54
55
	let modelTransferring = false;

56
	let modelTag = '';
57
58
59
60
	let digest = '';
	let pullProgress = null;

	let modelUploadMode = 'file';
Timothy J. Baek's avatar
Timothy J. Baek committed
61
	let modelInputFile = '';
62
	let modelFileUrl = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
63
	let modelFileContent = `TEMPLATE """{{ .System }}\nUSER: {{ .Prompt }}\nASSSISTANT: """\nPARAMETER num_ctx 4096\nPARAMETER stop "</s>"\nPARAMETER stop "USER:"\nPARAMETER stop "ASSSISTANT:"`;
64
65
	let modelFileDigest = '';
	let uploadProgress = null;
Timothy J. Baek's avatar
Timothy J. Baek committed
66

67
68
	let deleteModelTag = '';

Timothy J. Baek's avatar
Timothy J. Baek committed
69
	// Addons
70
	let titleAutoGenerate = true;
71
	let speechAutoSend = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
72
	let responseAutoCopy = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
73

Timothy J. Baek's avatar
Timothy J. Baek committed
74
75
	let gravatarEmail = '';
	let OPENAI_API_KEY = '';
76
	let OPENAI_API_BASE_URL = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
77

Timothy J. Baek's avatar
Timothy J. Baek committed
78
79
80
81
82
	// Auth
	let authEnabled = false;
	let authType = 'Basic';
	let authContent = '';

Timothy J. Baek's avatar
Timothy J. Baek committed
83
84
85
	// About
	let ollamaVersion = '';

86
	const checkOllamaConnection = async () => {
87
		if (API_BASE_URL === '') {
Timothy J. Baek's avatar
Timothy J. Baek committed
88
			API_BASE_URL = OLLAMA_API_BASE_URL;
89
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
90
		const _models = await getModels(API_BASE_URL, 'ollama');
91

Timothy J. Baek's avatar
Timothy J. Baek committed
92
		if (_models.length > 0) {
93
			toast.success('Server connection verified');
Timothy J. Baek's avatar
Timothy J. Baek committed
94
95
			await models.set(_models);

96
97
98
			saveSettings({
				API_BASE_URL: API_BASE_URL
			});
99
100
101
		}
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
102
103
104
105
106
107
108
109
110
111
112
113
114
	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);
	};

115
	const toggleRequestFormat = async () => {
116
117
118
119
120
121
122
123
124
		if (requestFormat === '') {
			requestFormat = 'json';
		} else {
			requestFormat = '';
		}

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

125
126
127
128
129
	const toggleSpeechAutoSend = async () => {
		speechAutoSend = !speechAutoSend;
		saveSettings({ speechAutoSend: speechAutoSend });
	};

130
131
132
133
134
	const toggleTitleAutoGenerate = async () => {
		titleAutoGenerate = !titleAutoGenerate;
		saveSettings({ titleAutoGenerate: titleAutoGenerate });
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
135
	const toggleNotification = async () => {
Timothy J. Baek's avatar
Timothy J. Baek committed
136
137
138
		const permission = await Notification.requestPermission();

		if (permission === 'granted') {
Timothy J. Baek's avatar
Timothy J. Baek committed
139
140
			notificationEnabled = !notificationEnabled;
			saveSettings({ notificationEnabled: notificationEnabled });
Timothy J. Baek's avatar
Timothy J. Baek committed
141
142
143
144
145
146
147
		} 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	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.'
			);
		}
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
170
171
172
173
	const toggleAuthHeader = async () => {
		authEnabled = !authEnabled;
	};

174
	const pullModelHandler = async () => {
175
		modelTransferring = true;
176
177
178
		const res = await fetch(`${API_BASE_URL}/pull`, {
			method: 'POST',
			headers: {
179
				'Content-Type': 'text/event-stream',
Timothy J. Baek's avatar
Timothy J. Baek committed
180
				...($settings.authHeader && { Authorization: $settings.authHeader }),
181
				...($user && { Authorization: `Bearer ${localStorage.token}` })
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
			},
			body: JSON.stringify({
				name: modelTag
			})
		});

		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;
						}
Timothy J. Baek's avatar
Timothy J. Baek committed
209
210
211
212

						if (data.detail) {
							throw data.detail;
						}
213
						if (data.status) {
Timothy J. Baek's avatar
Timothy J. Baek committed
214
							if (!data.digest) {
215
								toast.success(data.status);
Timothy J. Baek's avatar
Timothy J. Baek committed
216
217
218
219
220
221
222

								if (data.status === 'success') {
									const notification = new Notification(`Ollama`, {
										body: `Model '${modelTag}' has been successfully downloaded.`,
										icon: '/favicon.png'
									});
								}
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
							} else {
								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);
			}
		}

		modelTag = '';
241
242
		modelTransferring = false;

Timothy J. Baek's avatar
Timothy J. Baek committed
243
		models.set(await getModels());
244
245
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
	const calculateSHA256 = async (file) => {
		console.log(file);
		// Create a FileReader to read the file asynchronously
		const reader = new FileReader();

		// Define a promise to handle the file reading
		const readFile = new Promise((resolve, reject) => {
			reader.onload = () => resolve(reader.result);
			reader.onerror = reject;
		});

		// Read the file as an ArrayBuffer
		reader.readAsArrayBuffer(file);

		try {
			// Wait for the FileReader to finish reading the file
			const buffer = await readFile;

			// Convert the ArrayBuffer to a Uint8Array
			const uint8Array = new Uint8Array(buffer);

			// Calculate the SHA-256 hash using Web Crypto API
			const hashBuffer = await crypto.subtle.digest('SHA-256', uint8Array);

			// Convert the hash to a hexadecimal string
			const hashArray = Array.from(new Uint8Array(hashBuffer));
			const hashHex = hashArray.map((byte) => byte.toString(16).padStart(2, '0')).join('');

			return `sha256:${hashHex}`;
		} catch (error) {
			console.error('Error calculating SHA-256 hash:', error);
			throw error;
		}
	};

	const uploadModelHandler = async () => {
282
		modelTransferring = true;
283
		uploadProgress = 0;
Timothy J. Baek's avatar
Timothy J. Baek committed
284

Timothy J. Baek's avatar
Timothy J. Baek committed
285
		let uploaded = false;
286
287
		let fileResponse = null;
		let name = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
288

289
290
291
292
		if (modelUploadMode === 'file') {
			const file = modelInputFile[0];
			const formData = new FormData();
			formData.append('file', file);
Timothy J. Baek's avatar
Timothy J. Baek committed
293

294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
			fileResponse = await fetch(`${WEBUI_API_BASE_URL}/utils/upload`, {
				method: 'POST',
				headers: {
					...($settings.authHeader && { Authorization: $settings.authHeader }),
					...($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: {
					...($settings.authHeader && { Authorization: $settings.authHeader }),
					...($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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
				.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: /, ''));
334
335
336
337

							if (data.progress) {
								uploadProgress = data.progress;
							}
Timothy J. Baek's avatar
Timothy J. Baek committed
338
339
340
341
342
343

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

							if (data.done) {
344
345
								modelFileDigest = data.blob;
								name = data.name;
Timothy J. Baek's avatar
Timothy J. Baek committed
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
								uploaded = true;
							}
						}
					}
				} catch (error) {
					console.log(error);
				}
			}
		}

		if (uploaded) {
			const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/create`, {
				method: 'POST',
				headers: {
					'Content-Type': 'text/event-stream',
					...($settings.authHeader && { Authorization: $settings.authHeader }),
					...($user && { Authorization: `Bearer ${localStorage.token}` })
				},
				body: JSON.stringify({
365
366
					name: `${name}:latest`,
					modelfile: `FROM @${modelFileDigest}\n${modelFileContent}`
Timothy J. Baek's avatar
Timothy J. Baek committed
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
				})
			}).catch((err) => {
				console.log(err);
				return null;
			});

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

428
429
430
		modelFileUrl = '';
		modelInputFile = '';
		modelTransferring = false;
431
432
		uploadProgress = null;

Timothy J. Baek's avatar
Timothy J. Baek committed
433
434
435
		models.set(await getModels());
	};

436
437
438
439
	const deleteModelHandler = async () => {
		const res = await fetch(`${API_BASE_URL}/delete`, {
			method: 'DELETE',
			headers: {
440
				'Content-Type': 'text/event-stream',
Timothy J. Baek's avatar
Timothy J. Baek committed
441
				...($settings.authHeader && { Authorization: $settings.authHeader }),
442
				...($user && { Authorization: `Bearer ${localStorage.token}` })
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
			},
			body: JSON.stringify({
				name: deleteModelTag
			})
		});

		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 !== '' && line !== 'null') {
						console.log(line);
						let data = JSON.parse(line);
						console.log(data);

						if (data.error) {
							throw data.error;
						}
Timothy J. Baek's avatar
Timothy J. Baek committed
470
471
472
473
						if (data.detail) {
							throw data.detail;
						}

474
475
476
477
478
479
480
481
482
483
484
485
486
						if (data.status) {
						}
					} else {
						toast.success(`Deleted ${deleteModelTag}`);
					}
				}
			} catch (error) {
				console.log(error);
				toast.error(error);
			}
		}

		deleteModelTag = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
487
		models.set(await getModels());
488
	};
Timothy J. Baek's avatar
Timothy J. Baek committed
489

Timothy J. Baek's avatar
Timothy J. Baek committed
490
	const getModels = async (url = '', type = 'all') => {
491
		let models = [];
Timothy J. Baek's avatar
Timothy J. Baek committed
492
		const res = await fetch(`${url ? url : $settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/tags`, {
493
494
495
496
			method: 'GET',
			headers: {
				Accept: 'application/json',
				'Content-Type': 'application/json',
Timothy J. Baek's avatar
Timothy J. Baek committed
497
				...($settings.authHeader && { Authorization: $settings.authHeader }),
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
				...($user && { Authorization: `Bearer ${localStorage.token}` })
			}
		})
			.then(async (res) => {
				if (!res.ok) throw await res.json();
				return res.json();
			})
			.catch((error) => {
				console.log(error);
				if ('detail' in error) {
					toast.error(error.detail);
				} else {
					toast.error('Server connection failed');
				}
				return null;
			});
		console.log(res);
Timothy J. Baek's avatar
Timothy J. Baek committed
515
516
517
518
		models.push(...(res?.models ?? []));

		// If OpenAI API Key exists
		if (type === 'all' && $settings.OPENAI_API_KEY) {
519
520
			const API_BASE_URL = $settings.OPENAI_API_BASE_URL ?? 'https://api.openai.com/v1';

Timothy J. Baek's avatar
Timothy J. Baek committed
521
			// Validate OPENAI_API_KEY
522
			const openaiModelRes = await fetch(`${API_BASE_URL}/models`, {
Timothy J. Baek's avatar
Timothy J. Baek committed
523
524
525
526
				method: 'GET',
				headers: {
					'Content-Type': 'application/json',
					Authorization: `Bearer ${$settings.OPENAI_API_KEY}`
527
				}
Timothy J. Baek's avatar
Timothy J. Baek committed
528
529
530
531
532
533
534
535
536
537
538
			})
				.then(async (res) => {
					if (!res.ok) throw await res.json();
					return res.json();
				})
				.catch((error) => {
					console.log(error);
					toast.error(`OpenAI: ${error?.error?.message ?? 'Network Problem'}`);
					return null;
				});

539
540
541
			const openAIModels = Array.isArray(openaiModelRes)
				? openaiModelRes
				: openaiModelRes?.data ?? null;
Timothy J. Baek's avatar
Timothy J. Baek committed
542
543
544
545
546
547

			models.push(
				...(openAIModels
					? [
							{ name: 'hr' },
							...openAIModels
548
549
550
551
								.map((model) => ({ name: model.id, external: true }))
								.filter((model) =>
									API_BASE_URL.includes('openai') ? model.name.includes('gpt') : true
								)
Timothy J. Baek's avatar
Timothy J. Baek committed
552
553
554
					  ]
					: [])
			);
555
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
556
557

		return models;
558
559
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
560
	onMount(async () => {
Timothy J. Baek's avatar
Timothy J. Baek committed
561
		let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
562
563
564
		console.log(settings);

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

567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
		API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL;
		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 };

		titleAutoGenerate = settings.titleAutoGenerate ?? true;
		speechAutoSend = settings.speechAutoSend ?? false;
Timothy J. Baek's avatar
Timothy J. Baek committed
582
583
		responseAutoCopy = settings.responseAutoCopy ?? false;

584
585
		gravatarEmail = settings.gravatarEmail ?? '';
		OPENAI_API_KEY = settings.OPENAI_API_KEY ?? '';
586
		OPENAI_API_BASE_URL = settings.OPENAI_API_BASE_URL ?? 'https://api.openai.com/v1';
Timothy J. Baek's avatar
Timothy J. Baek committed
587
588
589
590
591
592

		authEnabled = settings.authHeader !== undefined ? true : false;
		if (authEnabled) {
			authType = settings.authHeader.split(' ')[0];
			authContent = settings.authHeader.split(' ')[1];
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
593
594
595
596
597
598
599

		ollamaVersion = await getOllamaVersion(
			API_BASE_URL ?? OLLAMA_API_BASE_URL,
			localStorage.token
		).catch((error) => {
			return '';
		});
Timothy J. Baek's avatar
Timothy J. Baek committed
600
	});
Timothy J. Baek's avatar
Timothy J. Baek committed
601
602
603
</script>

<Modal bind:show>
Timothy J. Baek's avatar
Timothy J. Baek committed
604
	<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
605
		<div class=" flex justify-between dark:text-gray-300 px-5 py-4">
Timothy J. Baek's avatar
Timothy J. Baek committed
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
			<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
625
		<hr class=" dark:border-gray-800" />
Timothy J. Baek's avatar
Timothy J. Baek committed
626

Timothy J. Baek's avatar
Timothy J. Baek committed
627
628
		<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
629
				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
630
631
			>
				<button
632
					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
633
					'general'
Timothy J. Baek's avatar
Timothy J. Baek committed
634
635
						? '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
636
					on:click={() => {
637
						selectedTab = 'general';
Timothy J. Baek's avatar
Timothy J. Baek committed
638
					}}
Timothy J. Baek's avatar
Timothy J. Baek committed
639
				>
Timothy J. Baek's avatar
Timothy J. Baek committed
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
					<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
657
				<button
658
659
					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
660
661
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
					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>

				<button
					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
683
					'models'
Timothy J. Baek's avatar
Timothy J. Baek committed
684
685
						? '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
686
					on:click={() => {
687
						selectedTab = 'models';
Timothy J. Baek's avatar
Timothy J. Baek committed
688
689
					}}
				>
Timothy J. Baek's avatar
Timothy J. Baek committed
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
					<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>
Timothy J. Baek's avatar
Timothy J. Baek committed
705
				</button>
706

707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
				<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>

731
				<button
732
733
					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
734
735
						? 'bg-gray-200 dark:bg-gray-700'
						: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
736
					on:click={() => {
737
						selectedTab = 'addons';
738
739
740
741
742
743
744
745
746
747
748
749
750
751
					}}
				>
					<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>
752
					<div class=" self-center">Add-ons</div>
753
				</button>
Timothy J. Baek's avatar
Timothy J. Baek committed
754

Timothy J. Baek's avatar
Timothy J. Baek committed
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
				{#if !$config || ($config && !$config.auth)}
					<button
						class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
						'auth'
							? 'bg-gray-200 dark:bg-gray-700'
							: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
						on:click={() => {
							selectedTab = 'auth';
						}}
					>
						<div class=" self-center mr-2">
							<svg
								xmlns="http://www.w3.org/2000/svg"
								viewBox="0 0 24 24"
								fill="currentColor"
								class="w-4 h-4"
							>
								<path
									fill-rule="evenodd"
									d="M12.516 2.17a.75.75 0 00-1.032 0 11.209 11.209 0 01-7.877 3.08.75.75 0 00-.722.515A12.74 12.74 0 002.25 9.75c0 5.942 4.064 10.933 9.563 12.348a.749.749 0 00.374 0c5.499-1.415 9.563-6.406 9.563-12.348 0-1.39-.223-2.73-.635-3.985a.75.75 0 00-.722-.516l-.143.001c-2.996 0-5.717-1.17-7.734-3.08zm3.094 8.016a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z"
									clip-rule="evenodd"
								/>
							</svg>
						</div>
						<div class=" self-center">Authentication</div>
					</button>
				{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
782

Timothy J. Baek's avatar
Timothy J. Baek committed
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
				<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
808
			</div>
809
			<div class="flex-1 md:min-h-[340px]">
810
				{#if selectedTab === 'general'}
Timothy J. Baek's avatar
Timothy J. Baek committed
811
					<div class="flex flex-col space-y-3">
Timothy J. Baek's avatar
Timothy J. Baek committed
812
						<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
813
814
815
816
							<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
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853

								<button
									class="p-1 px-3 text-xs flex rounded transition"
									on:click={() => {
										toggleTheme();
									}}
								>
									{#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>

										<span class="ml-2 self-center"> Dark </span>
									{:else}
										<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"> Light </span>
									{/if}
								</button>
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873

							<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
874
875
876
						</div>

						<hr class=" dark:border-gray-700" />
877
878
879
880
881
						<div>
							<div class=" mb-2.5 text-sm font-medium">Ollama Server URL</div>
							<div class="flex w-full">
								<div class="flex-1 mr-2">
									<input
Timothy J. Baek's avatar
Timothy J. Baek committed
882
										class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
883
884
885
886
887
										placeholder="Enter URL (e.g. http://localhost:11434/api)"
										bind:value={API_BASE_URL}
									/>
								</div>
								<button
Timothy J. Baek's avatar
Timothy J. Baek committed
888
									class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 rounded transition"
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
									on:click={() => {
										checkOllamaConnection();
									}}
								>
									<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>

Timothy J. Baek's avatar
Timothy J. Baek committed
908
							<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
909
								Trouble accessing Ollama? <a
Timothy J. Baek's avatar
Timothy J. Baek committed
910
									class=" text-gray-500 dark:text-gray-300 font-medium"
911
912
913
914
915
916
917
918
									href="https://github.com/ollama-webui/ollama-webui#troubleshooting"
									target="_blank"
								>
									Click here for help.
								</a>
							</div>
						</div>

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

Timothy J. Baek's avatar
Timothy J. Baek committed
921
						<div>
922
923
924
							<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
925
								class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
926
								rows="4"
Timothy J. Baek's avatar
Timothy J. Baek committed
927
928
							/>
						</div>
929

Timothy J. Baek's avatar
Timothy J. Baek committed
930
931
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
Timothy J. Baek's avatar
Timothy J. Baek committed
932
								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
933
								on:click={() => {
934
									saveSettings({
Timothy J. Baek's avatar
Timothy J. Baek committed
935
										API_BASE_URL: API_BASE_URL === '' ? OLLAMA_API_BASE_URL : API_BASE_URL,
936
937
										system: system !== '' ? system : undefined
									});
Timothy J. Baek's avatar
Timothy J. Baek committed
938
939
940
941
942
943
944
									show = false;
								}}
							>
								Save
							</button>
						</div>
					</div>
945
				{:else if selectedTab === 'advanced'}
946
947
948
					<div class="flex flex-col h-full justify-between text-sm">
						<div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-72">
							<div class=" text-sm font-medium">Parameters</div>
949

950
							<Advanced bind:options />
951
952
							<hr class=" dark:border-gray-700" />

953
							<div>
954
955
956
957
958
959
								<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={() => {
960
											toggleRequestFormat();
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
										}}
									>
										{#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>
981
						</div>
982

983
984
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
Timothy J. Baek's avatar
Timothy J. Baek committed
985
								class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
986
987
								on:click={() => {
									saveSettings({
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
										options: {
											seed: (options.seed !== 0 ? options.seed : undefined) ?? undefined,
											stop: options.stop !== '' ? options.stop : undefined,
											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,
											num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined
										}
1004
1005
1006
1007
1008
1009
1010
1011
									});
									show = false;
								}}
							>
								Save
							</button>
						</div>
					</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1012
				{:else if selectedTab === 'models'}
Timothy J. Baek's avatar
Timothy J. Baek committed
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
					<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
1026
										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
1027
1028
1029
										on:click={() => {
											pullModelHandler();
										}}
1030
										disabled={modelTransferring}
Timothy J. Baek's avatar
Timothy J. Baek committed
1031
									>
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
										{#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
1073
									</button>
Timothy J. Baek's avatar
Timothy J. Baek committed
1074
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1075
1076
1077
1078
1079
1080

								<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
									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
1081
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
1082
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1083

Timothy J. Baek's avatar
Timothy J. Baek committed
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
								{#if pullProgress !== null}
									<div class="mt-2">
										<div class=" mb-2 text-xs">Pull Progress</div>
										<div class="w-full rounded-full dark:bg-gray-800">
											<div
												class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
												style="width: {Math.max(15, pullProgress ?? 0)}%"
											>
												{pullProgress ?? 0}%
											</div>
										</div>
										<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
											{digest}
										</div>
									</div>
								{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1100
							</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1101
1102
							<hr class=" dark:border-gray-700" />

1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
							<form
								on:submit|preventDefault={() => {
									uploadModelHandler();
								}}
							>
								<div class=" mb-2 flex w-full justify-between">
									<div class="  text-sm font-medium">Upload a GGUF model</div>

									<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
1130
								<div class="flex w-full mb-1.5">
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
									<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
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
												<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
1176
									</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1177

1178
									{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
Timothy J. Baek's avatar
Timothy J. Baek committed
1179
										<button
1180
1181
1182
											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
1183
										>
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
											{#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
1225
1226
										</button>
									{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
1227
1228
								</div>

1229
								{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
Timothy J. Baek's avatar
Timothy J. Baek committed
1230
1231
1232
1233
1234
1235
									<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
1236
												rows="6"
Timothy J. Baek's avatar
Timothy J. Baek committed
1237
1238
1239
1240
1241
1242
1243
1244
1245
											/>
										</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
1246
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
1247
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1248

1249
								{#if uploadProgress !== null}
Timothy J. Baek's avatar
Timothy J. Baek committed
1250
									<div class="mt-2">
1251
										<div class=" mb-2 text-xs">Upload Progress</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1252
1253
1254
										<div class="w-full rounded-full dark:bg-gray-800">
											<div
												class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
1255
												style="width: {Math.max(15, uploadProgress ?? 0)}%"
Timothy J. Baek's avatar
Timothy J. Baek committed
1256
											>
1257
												{uploadProgress ?? 0}%
Timothy J. Baek's avatar
Timothy J. Baek committed
1258
1259
1260
											</div>
										</div>
										<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
1261
											{modelFileDigest}
Timothy J. Baek's avatar
Timothy J. Baek committed
1262
1263
1264
										</div>
									</div>
								{/if}
1265
							</form>
Timothy J. Baek's avatar
Timothy J. Baek committed
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
							<hr class=" dark:border-gray-700" />

							<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();
										}}
Timothy J. Baek's avatar
Timothy J. Baek committed
1295
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
										<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>
Timothy J. Baek's avatar
Timothy J. Baek committed
1310
1311
1312
							</div>
						</div>
					</div>
1313
1314
1315
1316
1317
1318
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
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
				{:else if selectedTab === 'external'}
					<form
						class="flex flex-col h-full justify-between space-y-3 text-sm"
						on:submit|preventDefault={() => {
							saveSettings({
								OPENAI_API_KEY: OPENAI_API_KEY !== '' ? OPENAI_API_KEY : undefined,
								OPENAI_API_BASE_URL: OPENAI_API_BASE_URL !== '' ? OPENAI_API_BASE_URL : undefined
							});
							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>

						<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>
1373
				{:else if selectedTab === 'addons'}
Timothy J. Baek's avatar
Timothy J. Baek committed
1374
1375
1376
1377
1378
					<form
						class="flex flex-col h-full justify-between space-y-3 text-sm"
						on:submit|preventDefault={() => {
							saveSettings({
								gravatarEmail: gravatarEmail !== '' ? gravatarEmail : undefined,
1379
								gravatarUrl: gravatarEmail !== '' ? getGravatarURL(gravatarEmail) : undefined
Timothy J. Baek's avatar
Timothy J. Baek committed
1380
1381
1382
1383
							});
							show = false;
						}}
					>
1384
						<div class=" space-y-3">
1385
							<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1386
1387
1388
1389
1390
								<div class=" mb-1 text-sm font-medium">WebUI Add-ons</div>

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

Timothy J. Baek's avatar
Timothy J. Baek committed
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
										<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>
1407

Timothy J. Baek's avatar
Timothy J. Baek committed
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
								<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>
1426
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448

								<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>
1449
1450
1451
							</div>

							<hr class=" dark:border-gray-700" />
Timothy J. Baek's avatar
Timothy J. Baek committed
1452
1453
1454
1455
1456
1457
1458
							<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
1459
											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
1460
1461
1462
1463
1464
1465
1466
											placeholder="Enter Your Email"
											bind:value={gravatarEmail}
											autocomplete="off"
											type="email"
										/>
									</div>
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1467
								<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
Timothy J. Baek's avatar
Timothy J. Baek committed
1468
									Changes user profile image to match your <a
Timothy J. Baek's avatar
Timothy J. Baek committed
1469
										class=" text-gray-500 dark:text-gray-300 font-medium"
Timothy J. Baek's avatar
Timothy J. Baek committed
1470
1471
1472
1473
1474
										href="https://gravatar.com/"
										target="_blank">Gravatar.</a
									>
								</div>
							</div>
1475
1476
						</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
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
1591
1592
1593
						<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 === 'auth'}
					<form
						class="flex flex-col h-full justify-between space-y-3 text-sm"
						on:submit|preventDefault={() => {
							console.log('auth save');
							saveSettings({
								authHeader: authEnabled ? `${authType} ${authContent}` : undefined
							});
							show = false;
						}}
					>
						<div class=" space-y-3">
							<div>
								<div class=" py-1 flex w-full justify-between">
									<div class=" self-center text-sm font-medium">Authorization Header</div>

									<button
										class="p-1 px-3 text-xs flex rounded transition"
										type="button"
										on:click={() => {
											toggleAuthHeader();
										}}
									>
										{#if authEnabled === true}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 24 24"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													fill-rule="evenodd"
													d="M12 1.5a5.25 5.25 0 00-5.25 5.25v3a3 3 0 00-3 3v6.75a3 3 0 003 3h10.5a3 3 0 003-3v-6.75a3 3 0 00-3-3v-3c0-2.9-2.35-5.25-5.25-5.25zm3.75 8.25v-3a3.75 3.75 0 10-7.5 0v3h7.5z"
													clip-rule="evenodd"
												/>
											</svg>

											<span class="ml-2 self-center"> On </span>
										{:else}
											<svg
												xmlns="http://www.w3.org/2000/svg"
												viewBox="0 0 24 24"
												fill="currentColor"
												class="w-4 h-4"
											>
												<path
													d="M18 1.5c2.9 0 5.25 2.35 5.25 5.25v3.75a.75.75 0 01-1.5 0V6.75a3.75 3.75 0 10-7.5 0v3a3 3 0 013 3v6.75a3 3 0 01-3 3H3.75a3 3 0 01-3-3v-6.75a3 3 0 013-3h9v-3c0-2.9 2.35-5.25 5.25-5.25z"
												/>
											</svg>

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

							{#if authEnabled}
								<hr class=" dark:border-gray-700" />

								<div class="mt-2">
									<div class=" py-1 flex w-full space-x-2">
										<button
											class=" py-1 font-semibold flex rounded transition"
											on:click={() => {
												authType = authType === 'Basic' ? 'Bearer' : 'Basic';
											}}
											type="button"
										>
											{#if authType === 'Basic'}
												<span class="self-center mr-2">Basic</span>
											{:else if authType === 'Bearer'}
												<span class="self-center mr-2">Bearer</span>
											{/if}
										</button>

										<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 Authorization Header Content"
												bind:value={authContent}
											/>
										</div>
									</div>
									<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
										Toggle between <span class=" text-gray-500 dark:text-gray-300 font-medium"
											>'Basic'</span
										>
										and <span class=" text-gray-500 dark:text-gray-300 font-medium">'Bearer'</span> by
										clicking on the label next to the input.
									</div>
								</div>

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

								<div>
									<div class=" mb-2.5 text-sm font-medium">Preview Authorization Header</div>
									<textarea
										value={JSON.stringify({
											Authorization: `${authType} ${authContent}`
										})}
										class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
										rows="2"
										disabled
									/>
								</div>
							{/if}
						</div>

1594
1595
						<div class="flex justify-end pt-3 text-sm font-medium">
							<button
Timothy J. Baek's avatar
Timothy J. Baek committed
1596
								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
1597
								type="submit"
1598
1599
1600
1601
							>
								Save
							</button>
						</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1602
					</form>
Timothy J. Baek's avatar
Timothy J. Baek committed
1603
				{:else if selectedTab === 'about'}
Timothy J. Baek's avatar
Timothy J. Baek committed
1604
					<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
1605
1606
1607
1608
						<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
1609
									<div class="flex-1 text-xs text-gray-700 dark:text-gray-200">
1610
										{$config && $config.version ? $config.version : WEB_UI_VERSION}
Timothy J. Baek's avatar
Timothy J. Baek committed
1611
									</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1612
1613
1614
1615
1616
								</div>
							</div>

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

Timothy J. Baek's avatar
Timothy J. Baek committed
1617
1618
1619
1620
							<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
1621
										{ollamaVersion ?? 'N/A'}
Timothy J. Baek's avatar
Timothy J. Baek committed
1622
1623
1624
1625
1626
1627
									</div>
								</div>
							</div>

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

Timothy J. Baek's avatar
Timothy J. Baek committed
1628
1629
1630
1631
1632
1633
1634
1635
1636
							<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>

							<div>
1637
1638
								<a href="https://github.com/ollama-webui/ollama-webui">
									<img
1639
										alt="Github Repo"
1640
1641
1642
										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
1643
1644
1645
							</div>
						</div>
					</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1646
1647
				{/if}
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1648
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
1649
1650
	</div>
</Modal>
1651
1652
1653
1654
1655
1656
1657
1658
1659

<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 */
	}

1660
1661
1662
1663
1664
1665
1666
1667
1668
	.tabs::-webkit-scrollbar {
		display: none; /* for Chrome, Safari and Opera */
	}

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

1669
1670
1671
1672
	input[type='number'] {
		-moz-appearance: textfield; /* Firefox */
	}
</style>