SettingsModal.svelte 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. <script lang="ts">
  2. import toast from 'svelte-french-toast';
  3. import fileSaver from 'file-saver';
  4. const { saveAs } = fileSaver;
  5. import { onMount } from 'svelte';
  6. import { config, models, settings, user, chats } from '$lib/stores';
  7. import { splitStream, getGravatarURL } from '$lib/utils';
  8. import {
  9. getOllamaVersion,
  10. getOllamaModels,
  11. getOllamaAPIUrl,
  12. updateOllamaAPIUrl,
  13. pullModel,
  14. createModel,
  15. deleteModel
  16. } from '$lib/apis/ollama';
  17. import { createNewChat, deleteAllChats, getAllChats, getChatList } from '$lib/apis/chats';
  18. import { WEB_UI_VERSION, WEBUI_API_BASE_URL } from '$lib/constants';
  19. import Advanced from './Settings/Advanced.svelte';
  20. import Modal from '../common/Modal.svelte';
  21. import { updateUserPassword } from '$lib/apis/auths';
  22. import { goto } from '$app/navigation';
  23. import Page from '../../../routes/(app)/+page.svelte';
  24. import {
  25. getOpenAIKey,
  26. getOpenAIModels,
  27. getOpenAIUrl,
  28. updateOpenAIKey,
  29. updateOpenAIUrl
  30. } from '$lib/apis/openai';
  31. export let show = false;
  32. const saveSettings = async (updated) => {
  33. console.log(updated);
  34. await settings.set({ ...$settings, ...updated });
  35. await models.set(await getModels());
  36. localStorage.setItem('settings', JSON.stringify($settings));
  37. };
  38. let selectedTab = 'general';
  39. // General
  40. let API_BASE_URL = '';
  41. let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'];
  42. let theme = 'dark';
  43. let notificationEnabled = false;
  44. let system = '';
  45. // Advanced
  46. let requestFormat = '';
  47. let options = {
  48. // Advanced
  49. seed: 0,
  50. temperature: '',
  51. repeat_penalty: '',
  52. repeat_last_n: '',
  53. mirostat: '',
  54. mirostat_eta: '',
  55. mirostat_tau: '',
  56. top_k: '',
  57. top_p: '',
  58. stop: '',
  59. tfs_z: '',
  60. num_ctx: '',
  61. num_predict: ''
  62. };
  63. // Models
  64. let modelTransferring = false;
  65. let modelTag = '';
  66. let digest = '';
  67. let pullProgress = null;
  68. let modelUploadMode = 'file';
  69. let modelInputFile = '';
  70. let modelFileUrl = '';
  71. let modelFileContent = `TEMPLATE """{{ .System }}\nUSER: {{ .Prompt }}\nASSSISTANT: """\nPARAMETER num_ctx 4096\nPARAMETER stop "</s>"\nPARAMETER stop "USER:"\nPARAMETER stop "ASSSISTANT:"`;
  72. let modelFileDigest = '';
  73. let uploadProgress = null;
  74. let deleteModelTag = '';
  75. // External
  76. let OPENAI_API_KEY = '';
  77. let OPENAI_API_BASE_URL = '';
  78. // Addons
  79. let titleAutoGenerate = true;
  80. let speechAutoSend = false;
  81. let responseAutoCopy = false;
  82. let gravatarEmail = '';
  83. let titleAutoGenerateModel = '';
  84. // Chats
  85. let importFiles;
  86. let showDeleteConfirm = false;
  87. const importChats = async (_chats) => {
  88. for (const chat of _chats) {
  89. console.log(chat);
  90. await createNewChat(localStorage.token, chat);
  91. }
  92. await chats.set(await getChatList(localStorage.token));
  93. };
  94. const exportChats = async () => {
  95. let blob = new Blob([JSON.stringify(await getAllChats(localStorage.token))], {
  96. type: 'application/json'
  97. });
  98. saveAs(blob, `chat-export-${Date.now()}.json`);
  99. };
  100. $: if (importFiles) {
  101. console.log(importFiles);
  102. let reader = new FileReader();
  103. reader.onload = (event) => {
  104. let chats = JSON.parse(event.target.result);
  105. console.log(chats);
  106. importChats(chats);
  107. };
  108. reader.readAsText(importFiles[0]);
  109. }
  110. const deleteChats = async () => {
  111. await goto('/');
  112. await deleteAllChats(localStorage.token);
  113. await chats.set(await getChatList(localStorage.token));
  114. };
  115. // Auth
  116. let authEnabled = false;
  117. let authType = 'Basic';
  118. let authContent = '';
  119. // Account
  120. let currentPassword = '';
  121. let newPassword = '';
  122. let newPasswordConfirm = '';
  123. // About
  124. let ollamaVersion = '';
  125. const updateOllamaAPIUrlHandler = async () => {
  126. API_BASE_URL = await updateOllamaAPIUrl(localStorage.token, API_BASE_URL);
  127. const _models = await getModels('ollama');
  128. if (_models.length > 0) {
  129. toast.success('Server connection verified');
  130. await models.set(_models);
  131. }
  132. };
  133. const updateOpenAIHandler = async () => {
  134. OPENAI_API_BASE_URL = await updateOpenAIUrl(localStorage.token, OPENAI_API_BASE_URL);
  135. OPENAI_API_KEY = await updateOpenAIKey(localStorage.token, OPENAI_API_KEY);
  136. await models.set(await getModels());
  137. };
  138. const toggleTheme = async () => {
  139. if (theme === 'dark') {
  140. theme = 'light';
  141. } else {
  142. theme = 'dark';
  143. }
  144. localStorage.theme = theme;
  145. document.documentElement.classList.remove(theme === 'dark' ? 'light' : 'dark');
  146. document.documentElement.classList.add(theme);
  147. };
  148. const toggleRequestFormat = async () => {
  149. if (requestFormat === '') {
  150. requestFormat = 'json';
  151. } else {
  152. requestFormat = '';
  153. }
  154. saveSettings({ requestFormat: requestFormat !== '' ? requestFormat : undefined });
  155. };
  156. const toggleSpeechAutoSend = async () => {
  157. speechAutoSend = !speechAutoSend;
  158. saveSettings({ speechAutoSend: speechAutoSend });
  159. };
  160. const toggleTitleAutoGenerate = async () => {
  161. titleAutoGenerate = !titleAutoGenerate;
  162. saveSettings({ titleAutoGenerate: titleAutoGenerate });
  163. };
  164. const toggleNotification = async () => {
  165. const permission = await Notification.requestPermission();
  166. if (permission === 'granted') {
  167. notificationEnabled = !notificationEnabled;
  168. saveSettings({ notificationEnabled: notificationEnabled });
  169. } else {
  170. toast.error(
  171. 'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
  172. );
  173. }
  174. };
  175. const toggleResponseAutoCopy = async () => {
  176. const permission = await navigator.clipboard
  177. .readText()
  178. .then(() => {
  179. return 'granted';
  180. })
  181. .catch(() => {
  182. return '';
  183. });
  184. console.log(permission);
  185. if (permission === 'granted') {
  186. responseAutoCopy = !responseAutoCopy;
  187. saveSettings({ responseAutoCopy: responseAutoCopy });
  188. } else {
  189. toast.error(
  190. 'Clipboard write permission denied. Please check your browser settings to grant the necessary access.'
  191. );
  192. }
  193. };
  194. const toggleAuthHeader = async () => {
  195. authEnabled = !authEnabled;
  196. };
  197. const pullModelHandler = async () => {
  198. modelTransferring = true;
  199. const res = await pullModel(localStorage.token, modelTag);
  200. if (res) {
  201. const reader = res.body
  202. .pipeThrough(new TextDecoderStream())
  203. .pipeThrough(splitStream('\n'))
  204. .getReader();
  205. while (true) {
  206. const { value, done } = await reader.read();
  207. if (done) break;
  208. try {
  209. let lines = value.split('\n');
  210. for (const line of lines) {
  211. if (line !== '') {
  212. console.log(line);
  213. let data = JSON.parse(line);
  214. console.log(data);
  215. if (data.error) {
  216. throw data.error;
  217. }
  218. if (data.detail) {
  219. throw data.detail;
  220. }
  221. if (data.status) {
  222. if (!data.digest) {
  223. toast.success(data.status);
  224. if (data.status === 'success') {
  225. const notification = new Notification(`Ollama`, {
  226. body: `Model '${modelTag}' has been successfully downloaded.`,
  227. icon: '/favicon.png'
  228. });
  229. }
  230. } else {
  231. digest = data.digest;
  232. if (data.completed) {
  233. pullProgress = Math.round((data.completed / data.total) * 1000) / 10;
  234. } else {
  235. pullProgress = 100;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. } catch (error) {
  242. console.log(error);
  243. toast.error(error);
  244. }
  245. }
  246. }
  247. modelTag = '';
  248. modelTransferring = false;
  249. models.set(await getModels());
  250. };
  251. const calculateSHA256 = async (file) => {
  252. console.log(file);
  253. // Create a FileReader to read the file asynchronously
  254. const reader = new FileReader();
  255. // Define a promise to handle the file reading
  256. const readFile = new Promise((resolve, reject) => {
  257. reader.onload = () => resolve(reader.result);
  258. reader.onerror = reject;
  259. });
  260. // Read the file as an ArrayBuffer
  261. reader.readAsArrayBuffer(file);
  262. try {
  263. // Wait for the FileReader to finish reading the file
  264. const buffer = await readFile;
  265. // Convert the ArrayBuffer to a Uint8Array
  266. const uint8Array = new Uint8Array(buffer);
  267. // Calculate the SHA-256 hash using Web Crypto API
  268. const hashBuffer = await crypto.subtle.digest('SHA-256', uint8Array);
  269. // Convert the hash to a hexadecimal string
  270. const hashArray = Array.from(new Uint8Array(hashBuffer));
  271. const hashHex = hashArray.map((byte) => byte.toString(16).padStart(2, '0')).join('');
  272. return `sha256:${hashHex}`;
  273. } catch (error) {
  274. console.error('Error calculating SHA-256 hash:', error);
  275. throw error;
  276. }
  277. };
  278. const uploadModelHandler = async () => {
  279. modelTransferring = true;
  280. uploadProgress = 0;
  281. let uploaded = false;
  282. let fileResponse = null;
  283. let name = '';
  284. if (modelUploadMode === 'file') {
  285. const file = modelInputFile[0];
  286. const formData = new FormData();
  287. formData.append('file', file);
  288. fileResponse = await fetch(`${WEBUI_API_BASE_URL}/utils/upload`, {
  289. method: 'POST',
  290. headers: {
  291. ...($settings.authHeader && { Authorization: $settings.authHeader }),
  292. ...($user && { Authorization: `Bearer ${localStorage.token}` })
  293. },
  294. body: formData
  295. }).catch((error) => {
  296. console.log(error);
  297. return null;
  298. });
  299. } else {
  300. fileResponse = await fetch(`${WEBUI_API_BASE_URL}/utils/download?url=${modelFileUrl}`, {
  301. method: 'GET',
  302. headers: {
  303. ...($settings.authHeader && { Authorization: $settings.authHeader }),
  304. ...($user && { Authorization: `Bearer ${localStorage.token}` })
  305. }
  306. }).catch((error) => {
  307. console.log(error);
  308. return null;
  309. });
  310. }
  311. if (fileResponse && fileResponse.ok) {
  312. const reader = fileResponse.body
  313. .pipeThrough(new TextDecoderStream())
  314. .pipeThrough(splitStream('\n'))
  315. .getReader();
  316. while (true) {
  317. const { value, done } = await reader.read();
  318. if (done) break;
  319. try {
  320. let lines = value.split('\n');
  321. for (const line of lines) {
  322. if (line !== '') {
  323. let data = JSON.parse(line.replace(/^data: /, ''));
  324. if (data.progress) {
  325. uploadProgress = data.progress;
  326. }
  327. if (data.error) {
  328. throw data.error;
  329. }
  330. if (data.done) {
  331. modelFileDigest = data.blob;
  332. name = data.name;
  333. uploaded = true;
  334. }
  335. }
  336. }
  337. } catch (error) {
  338. console.log(error);
  339. }
  340. }
  341. }
  342. if (uploaded) {
  343. const res = await createModel(
  344. localStorage.token,
  345. `${name}:latest`,
  346. `FROM @${modelFileDigest}\n${modelFileContent}`
  347. );
  348. if (res && res.ok) {
  349. const reader = res.body
  350. .pipeThrough(new TextDecoderStream())
  351. .pipeThrough(splitStream('\n'))
  352. .getReader();
  353. while (true) {
  354. const { value, done } = await reader.read();
  355. if (done) break;
  356. try {
  357. let lines = value.split('\n');
  358. for (const line of lines) {
  359. if (line !== '') {
  360. console.log(line);
  361. let data = JSON.parse(line);
  362. console.log(data);
  363. if (data.error) {
  364. throw data.error;
  365. }
  366. if (data.detail) {
  367. throw data.detail;
  368. }
  369. if (data.status) {
  370. if (
  371. !data.digest &&
  372. !data.status.includes('writing') &&
  373. !data.status.includes('sha256')
  374. ) {
  375. toast.success(data.status);
  376. } else {
  377. if (data.digest) {
  378. digest = data.digest;
  379. if (data.completed) {
  380. pullProgress = Math.round((data.completed / data.total) * 1000) / 10;
  381. } else {
  382. pullProgress = 100;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. } catch (error) {
  390. console.log(error);
  391. toast.error(error);
  392. }
  393. }
  394. }
  395. }
  396. modelFileUrl = '';
  397. modelInputFile = '';
  398. modelTransferring = false;
  399. uploadProgress = null;
  400. models.set(await getModels());
  401. };
  402. const deleteModelHandler = async () => {
  403. const res = await deleteModel(localStorage.token, deleteModelTag).catch((error) => {
  404. toast.error(error);
  405. });
  406. if (res) {
  407. toast.success(`Deleted ${deleteModelTag}`);
  408. }
  409. deleteModelTag = '';
  410. models.set(await getModels());
  411. };
  412. const getModels = async (type = 'all') => {
  413. const models = [];
  414. models.push(
  415. ...(await getOllamaModels(localStorage.token).catch((error) => {
  416. toast.error(error);
  417. return [];
  418. }))
  419. );
  420. // If OpenAI API Key exists
  421. if (type === 'all' && OPENAI_API_KEY) {
  422. const openAIModels = await getOpenAIModels(localStorage.token).catch((error) => {
  423. console.log(error);
  424. return null;
  425. });
  426. models.push(...(openAIModels ? [{ name: 'hr' }, ...openAIModels] : []));
  427. }
  428. return models;
  429. };
  430. const updatePasswordHandler = async () => {
  431. if (newPassword === newPasswordConfirm) {
  432. const res = await updateUserPassword(localStorage.token, currentPassword, newPassword).catch(
  433. (error) => {
  434. toast.error(error);
  435. return null;
  436. }
  437. );
  438. if (res) {
  439. toast.success('Successfully updated.');
  440. }
  441. currentPassword = '';
  442. newPassword = '';
  443. newPasswordConfirm = '';
  444. } else {
  445. toast.error(
  446. `The passwords you entered don't quite match. Please double-check and try again.`
  447. );
  448. newPassword = '';
  449. newPasswordConfirm = '';
  450. }
  451. };
  452. onMount(async () => {
  453. console.log('settings', $user.role === 'admin');
  454. if ($user.role === 'admin') {
  455. API_BASE_URL = await getOllamaAPIUrl(localStorage.token);
  456. OPENAI_API_BASE_URL = await getOpenAIUrl(localStorage.token);
  457. OPENAI_API_KEY = await getOpenAIKey(localStorage.token);
  458. }
  459. let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
  460. console.log(settings);
  461. theme = localStorage.theme ?? 'dark';
  462. notificationEnabled = settings.notificationEnabled ?? false;
  463. system = settings.system ?? '';
  464. requestFormat = settings.requestFormat ?? '';
  465. options.seed = settings.seed ?? 0;
  466. options.temperature = settings.temperature ?? '';
  467. options.repeat_penalty = settings.repeat_penalty ?? '';
  468. options.top_k = settings.top_k ?? '';
  469. options.top_p = settings.top_p ?? '';
  470. options.num_ctx = settings.num_ctx ?? '';
  471. options = { ...options, ...settings.options };
  472. options.stop = (settings?.options?.stop ?? []).join(',');
  473. titleAutoGenerate = settings.titleAutoGenerate ?? true;
  474. speechAutoSend = settings.speechAutoSend ?? false;
  475. responseAutoCopy = settings.responseAutoCopy ?? false;
  476. titleAutoGenerateModel = settings.titleAutoGenerateModel ?? '';
  477. gravatarEmail = settings.gravatarEmail ?? '';
  478. authEnabled = settings.authHeader !== undefined ? true : false;
  479. if (authEnabled) {
  480. authType = settings.authHeader.split(' ')[0];
  481. authContent = settings.authHeader.split(' ')[1];
  482. }
  483. ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => {
  484. return '';
  485. });
  486. });
  487. </script>
  488. <Modal bind:show>
  489. <div>
  490. <div class=" flex justify-between dark:text-gray-300 px-5 py-4">
  491. <div class=" text-lg font-medium self-center">Settings</div>
  492. <button
  493. class="self-center"
  494. on:click={() => {
  495. show = false;
  496. }}
  497. >
  498. <svg
  499. xmlns="http://www.w3.org/2000/svg"
  500. viewBox="0 0 20 20"
  501. fill="currentColor"
  502. class="w-5 h-5"
  503. >
  504. <path
  505. 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"
  506. />
  507. </svg>
  508. </button>
  509. </div>
  510. <hr class=" dark:border-gray-800" />
  511. <div class="flex flex-col md:flex-row w-full p-4 md:space-x-4">
  512. <div
  513. 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"
  514. >
  515. <button
  516. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  517. 'general'
  518. ? 'bg-gray-200 dark:bg-gray-700'
  519. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  520. on:click={() => {
  521. selectedTab = 'general';
  522. }}
  523. >
  524. <div class=" self-center mr-2">
  525. <svg
  526. xmlns="http://www.w3.org/2000/svg"
  527. viewBox="0 0 20 20"
  528. fill="currentColor"
  529. class="w-4 h-4"
  530. >
  531. <path
  532. fill-rule="evenodd"
  533. 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"
  534. clip-rule="evenodd"
  535. />
  536. </svg>
  537. </div>
  538. <div class=" self-center">General</div>
  539. </button>
  540. <button
  541. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  542. 'advanced'
  543. ? 'bg-gray-200 dark:bg-gray-700'
  544. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  545. on:click={() => {
  546. selectedTab = 'advanced';
  547. }}
  548. >
  549. <div class=" self-center mr-2">
  550. <svg
  551. xmlns="http://www.w3.org/2000/svg"
  552. viewBox="0 0 20 20"
  553. fill="currentColor"
  554. class="w-4 h-4"
  555. >
  556. <path
  557. 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"
  558. />
  559. </svg>
  560. </div>
  561. <div class=" self-center">Advanced</div>
  562. </button>
  563. {#if $user?.role === 'admin'}
  564. <button
  565. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  566. 'models'
  567. ? 'bg-gray-200 dark:bg-gray-700'
  568. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  569. on:click={() => {
  570. selectedTab = 'models';
  571. }}
  572. >
  573. <div class=" self-center mr-2">
  574. <svg
  575. xmlns="http://www.w3.org/2000/svg"
  576. viewBox="0 0 20 20"
  577. fill="currentColor"
  578. class="w-4 h-4"
  579. >
  580. <path
  581. fill-rule="evenodd"
  582. 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"
  583. clip-rule="evenodd"
  584. />
  585. </svg>
  586. </div>
  587. <div class=" self-center">Models</div>
  588. </button>
  589. <button
  590. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  591. 'external'
  592. ? 'bg-gray-200 dark:bg-gray-700'
  593. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  594. on:click={() => {
  595. selectedTab = 'external';
  596. }}
  597. >
  598. <div class=" self-center mr-2">
  599. <svg
  600. xmlns="http://www.w3.org/2000/svg"
  601. viewBox="0 0 16 16"
  602. fill="currentColor"
  603. class="w-4 h-4"
  604. >
  605. <path
  606. 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"
  607. />
  608. </svg>
  609. </div>
  610. <div class=" self-center">External</div>
  611. </button>
  612. {/if}
  613. <button
  614. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  615. 'addons'
  616. ? 'bg-gray-200 dark:bg-gray-700'
  617. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  618. on:click={() => {
  619. selectedTab = 'addons';
  620. }}
  621. >
  622. <div class=" self-center mr-2">
  623. <svg
  624. xmlns="http://www.w3.org/2000/svg"
  625. viewBox="0 0 20 20"
  626. fill="currentColor"
  627. class="w-4 h-4"
  628. >
  629. <path
  630. 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"
  631. />
  632. </svg>
  633. </div>
  634. <div class=" self-center">Add-ons</div>
  635. </button>
  636. <button
  637. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  638. 'chats'
  639. ? 'bg-gray-200 dark:bg-gray-700'
  640. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  641. on:click={() => {
  642. selectedTab = 'chats';
  643. }}
  644. >
  645. <div class=" self-center mr-2">
  646. <svg
  647. xmlns="http://www.w3.org/2000/svg"
  648. viewBox="0 0 16 16"
  649. fill="currentColor"
  650. class="w-4 h-4"
  651. >
  652. <path
  653. fill-rule="evenodd"
  654. 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"
  655. clip-rule="evenodd"
  656. />
  657. </svg>
  658. </div>
  659. <div class=" self-center">Chats</div>
  660. </button>
  661. {#if !$config || ($config && !$config.auth)}
  662. <button
  663. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  664. 'auth'
  665. ? 'bg-gray-200 dark:bg-gray-700'
  666. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  667. on:click={() => {
  668. selectedTab = 'auth';
  669. }}
  670. >
  671. <div class=" self-center mr-2">
  672. <svg
  673. xmlns="http://www.w3.org/2000/svg"
  674. viewBox="0 0 24 24"
  675. fill="currentColor"
  676. class="w-4 h-4"
  677. >
  678. <path
  679. fill-rule="evenodd"
  680. 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"
  681. clip-rule="evenodd"
  682. />
  683. </svg>
  684. </div>
  685. <div class=" self-center">Authentication</div>
  686. </button>
  687. {/if}
  688. <button
  689. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  690. 'account'
  691. ? 'bg-gray-200 dark:bg-gray-700'
  692. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  693. on:click={() => {
  694. selectedTab = 'account';
  695. }}
  696. >
  697. <div class=" self-center mr-2">
  698. <svg
  699. xmlns="http://www.w3.org/2000/svg"
  700. viewBox="0 0 16 16"
  701. fill="currentColor"
  702. class="w-4 h-4"
  703. >
  704. <path
  705. fill-rule="evenodd"
  706. 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"
  707. clip-rule="evenodd"
  708. />
  709. </svg>
  710. </div>
  711. <div class=" self-center">Account</div>
  712. </button>
  713. <button
  714. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  715. 'about'
  716. ? 'bg-gray-200 dark:bg-gray-700'
  717. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  718. on:click={() => {
  719. selectedTab = 'about';
  720. }}
  721. >
  722. <div class=" self-center mr-2">
  723. <svg
  724. xmlns="http://www.w3.org/2000/svg"
  725. viewBox="0 0 20 20"
  726. fill="currentColor"
  727. class="w-4 h-4"
  728. >
  729. <path
  730. fill-rule="evenodd"
  731. 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"
  732. clip-rule="evenodd"
  733. />
  734. </svg>
  735. </div>
  736. <div class=" self-center">About</div>
  737. </button>
  738. </div>
  739. <div class="flex-1 md:min-h-[340px]">
  740. {#if selectedTab === 'general'}
  741. <div class="flex flex-col space-y-3">
  742. <div>
  743. <div class=" mb-1 text-sm font-medium">WebUI Settings</div>
  744. <div class=" py-0.5 flex w-full justify-between">
  745. <div class=" self-center text-xs font-medium">Theme</div>
  746. <!-- <button
  747. class="p-1 px-3 text-xs flex rounded transition"
  748. on:click={() => {
  749. toggleTheme();
  750. }}
  751. >
  752. </button> -->
  753. <div class="flex items-center relative">
  754. <div class=" absolute right-16">
  755. {#if theme === 'dark'}
  756. <svg
  757. xmlns="http://www.w3.org/2000/svg"
  758. viewBox="0 0 20 20"
  759. fill="currentColor"
  760. class="w-4 h-4"
  761. >
  762. <path
  763. fill-rule="evenodd"
  764. 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"
  765. clip-rule="evenodd"
  766. />
  767. </svg>
  768. {:else if theme === 'light'}
  769. <svg
  770. xmlns="http://www.w3.org/2000/svg"
  771. viewBox="0 0 20 20"
  772. fill="currentColor"
  773. class="w-4 h-4 self-center"
  774. >
  775. <path
  776. 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"
  777. />
  778. </svg>
  779. {/if}
  780. </div>
  781. <select
  782. class="w-fit pr-8 rounded py-2 px-2 text-xs bg-transparent outline-none text-right"
  783. bind:value={theme}
  784. placeholder="Select a theme"
  785. on:change={(e) => {
  786. localStorage.theme = theme;
  787. themes
  788. .filter((e) => e !== theme)
  789. .forEach((e) => {
  790. e.split(' ').forEach((e) => {
  791. document.documentElement.classList.remove(e);
  792. });
  793. });
  794. theme.split(' ').forEach((e) => {
  795. document.documentElement.classList.add(e);
  796. });
  797. console.log(theme);
  798. }}
  799. >
  800. <option value="dark">Dark</option>
  801. <option value="light">Light</option>
  802. <option value="rose-pine dark">Rosé Pine</option>
  803. <option value="rose-pine-dawn light">Rosé Pine Dawn</option>
  804. </select>
  805. </div>
  806. </div>
  807. <div>
  808. <div class=" py-0.5 flex w-full justify-between">
  809. <div class=" self-center text-xs font-medium">Notification</div>
  810. <button
  811. class="p-1 px-3 text-xs flex rounded transition"
  812. on:click={() => {
  813. toggleNotification();
  814. }}
  815. type="button"
  816. >
  817. {#if notificationEnabled === true}
  818. <span class="ml-2 self-center">On</span>
  819. {:else}
  820. <span class="ml-2 self-center">Off</span>
  821. {/if}
  822. </button>
  823. </div>
  824. </div>
  825. </div>
  826. {#if $user.role === 'admin'}
  827. <hr class=" dark:border-gray-700" />
  828. <div>
  829. <div class=" mb-2.5 text-sm font-medium">Ollama API URL</div>
  830. <div class="flex w-full">
  831. <div class="flex-1 mr-2">
  832. <input
  833. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  834. placeholder="Enter URL (e.g. http://localhost:11434/api)"
  835. bind:value={API_BASE_URL}
  836. />
  837. </div>
  838. <button
  839. class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 rounded transition"
  840. on:click={() => {
  841. updateOllamaAPIUrlHandler();
  842. }}
  843. >
  844. <svg
  845. xmlns="http://www.w3.org/2000/svg"
  846. viewBox="0 0 20 20"
  847. fill="currentColor"
  848. class="w-4 h-4"
  849. >
  850. <path
  851. fill-rule="evenodd"
  852. 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"
  853. clip-rule="evenodd"
  854. />
  855. </svg>
  856. </button>
  857. </div>
  858. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  859. Trouble accessing Ollama?
  860. <a
  861. class=" text-gray-300 font-medium"
  862. href="https://github.com/ollama-webui/ollama-webui#troubleshooting"
  863. target="_blank"
  864. >
  865. Click here for help.
  866. </a>
  867. </div>
  868. </div>
  869. {/if}
  870. <hr class=" dark:border-gray-700" />
  871. <div>
  872. <div class=" mb-2.5 text-sm font-medium">System Prompt</div>
  873. <textarea
  874. bind:value={system}
  875. class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
  876. rows="4"
  877. />
  878. </div>
  879. <div class="flex justify-end pt-3 text-sm font-medium">
  880. <button
  881. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  882. on:click={() => {
  883. saveSettings({
  884. system: system !== '' ? system : undefined
  885. });
  886. show = false;
  887. }}
  888. >
  889. Save
  890. </button>
  891. </div>
  892. </div>
  893. {:else if selectedTab === 'advanced'}
  894. <div class="flex flex-col h-full justify-between text-sm">
  895. <div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-72">
  896. <div class=" text-sm font-medium">Parameters</div>
  897. <Advanced bind:options />
  898. <hr class=" dark:border-gray-700" />
  899. <div>
  900. <div class=" py-1 flex w-full justify-between">
  901. <div class=" self-center text-sm font-medium">Request Mode</div>
  902. <button
  903. class="p-1 px-3 text-xs flex rounded transition"
  904. on:click={() => {
  905. toggleRequestFormat();
  906. }}
  907. >
  908. {#if requestFormat === ''}
  909. <span class="ml-2 self-center"> Default </span>
  910. {:else if requestFormat === 'json'}
  911. <!-- <svg
  912. xmlns="http://www.w3.org/2000/svg"
  913. viewBox="0 0 20 20"
  914. fill="currentColor"
  915. class="w-4 h-4 self-center"
  916. >
  917. <path
  918. 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"
  919. />
  920. </svg> -->
  921. <span class="ml-2 self-center"> JSON </span>
  922. {/if}
  923. </button>
  924. </div>
  925. </div>
  926. </div>
  927. <div class="flex justify-end pt-3 text-sm font-medium">
  928. <button
  929. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  930. on:click={() => {
  931. saveSettings({
  932. options: {
  933. seed: (options.seed !== 0 ? options.seed : undefined) ?? undefined,
  934. stop:
  935. options.stop !== '' ? options.stop.split(',').filter((e) => e) : undefined,
  936. temperature: options.temperature !== '' ? options.temperature : undefined,
  937. repeat_penalty:
  938. options.repeat_penalty !== '' ? options.repeat_penalty : undefined,
  939. repeat_last_n:
  940. options.repeat_last_n !== '' ? options.repeat_last_n : undefined,
  941. mirostat: options.mirostat !== '' ? options.mirostat : undefined,
  942. mirostat_eta: options.mirostat_eta !== '' ? options.mirostat_eta : undefined,
  943. mirostat_tau: options.mirostat_tau !== '' ? options.mirostat_tau : undefined,
  944. top_k: options.top_k !== '' ? options.top_k : undefined,
  945. top_p: options.top_p !== '' ? options.top_p : undefined,
  946. tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
  947. num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined,
  948. num_predict: options.num_predict !== '' ? options.num_predict : undefined
  949. }
  950. });
  951. show = false;
  952. }}
  953. >
  954. Save
  955. </button>
  956. </div>
  957. </div>
  958. {:else if selectedTab === 'models'}
  959. <div class="flex flex-col h-full justify-between text-sm">
  960. <div class=" space-y-3 pr-1.5 overflow-y-scroll h-80">
  961. <div>
  962. <div class=" mb-2.5 text-sm font-medium">Pull a model from Ollama.ai</div>
  963. <div class="flex w-full">
  964. <div class="flex-1 mr-2">
  965. <input
  966. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  967. placeholder="Enter model tag (e.g. mistral:7b)"
  968. bind:value={modelTag}
  969. />
  970. </div>
  971. <button
  972. class="px-3 text-gray-100 bg-emerald-600 hover:bg-emerald-700 disabled:bg-gray-700 disabled:cursor-not-allowed rounded transition"
  973. on:click={() => {
  974. pullModelHandler();
  975. }}
  976. disabled={modelTransferring}
  977. >
  978. {#if modelTransferring}
  979. <div class="self-center">
  980. <svg
  981. class=" w-4 h-4"
  982. viewBox="0 0 24 24"
  983. fill="currentColor"
  984. xmlns="http://www.w3.org/2000/svg"
  985. ><style>
  986. .spinner_ajPY {
  987. transform-origin: center;
  988. animation: spinner_AtaB 0.75s infinite linear;
  989. }
  990. @keyframes spinner_AtaB {
  991. 100% {
  992. transform: rotate(360deg);
  993. }
  994. }
  995. </style><path
  996. 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"
  997. opacity=".25"
  998. /><path
  999. 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"
  1000. class="spinner_ajPY"
  1001. /></svg
  1002. >
  1003. </div>
  1004. {:else}
  1005. <svg
  1006. xmlns="http://www.w3.org/2000/svg"
  1007. viewBox="0 0 16 16"
  1008. fill="currentColor"
  1009. class="w-4 h-4"
  1010. >
  1011. <path
  1012. 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"
  1013. />
  1014. <path
  1015. 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"
  1016. />
  1017. </svg>
  1018. {/if}
  1019. </button>
  1020. </div>
  1021. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1022. To access the available model names for downloading, <a
  1023. class=" text-gray-500 dark:text-gray-300 font-medium"
  1024. href="https://ollama.ai/library"
  1025. target="_blank">click here.</a
  1026. >
  1027. </div>
  1028. {#if pullProgress !== null}
  1029. <div class="mt-2">
  1030. <div class=" mb-2 text-xs">Pull Progress</div>
  1031. <div class="w-full rounded-full dark:bg-gray-800">
  1032. <div
  1033. class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
  1034. style="width: {Math.max(15, pullProgress ?? 0)}%"
  1035. >
  1036. {pullProgress ?? 0}%
  1037. </div>
  1038. </div>
  1039. <div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
  1040. {digest}
  1041. </div>
  1042. </div>
  1043. {/if}
  1044. </div>
  1045. <hr class=" dark:border-gray-700" />
  1046. <div>
  1047. <div class=" mb-2.5 text-sm font-medium">Delete a model</div>
  1048. <div class="flex w-full">
  1049. <div class="flex-1 mr-2">
  1050. <select
  1051. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1052. bind:value={deleteModelTag}
  1053. placeholder="Select a model"
  1054. >
  1055. {#if !deleteModelTag}
  1056. <option value="" disabled selected>Select a model</option>
  1057. {/if}
  1058. {#each $models.filter((m) => m.size != null) as model}
  1059. <option value={model.name} class="bg-gray-100 dark:bg-gray-700"
  1060. >{model.name +
  1061. ' (' +
  1062. (model.size / 1024 ** 3).toFixed(1) +
  1063. ' GB)'}</option
  1064. >
  1065. {/each}
  1066. </select>
  1067. </div>
  1068. <button
  1069. class="px-3 bg-red-700 hover:bg-red-800 text-gray-100 rounded transition"
  1070. on:click={() => {
  1071. deleteModelHandler();
  1072. }}
  1073. >
  1074. <svg
  1075. xmlns="http://www.w3.org/2000/svg"
  1076. viewBox="0 0 16 16"
  1077. fill="currentColor"
  1078. class="w-4 h-4"
  1079. >
  1080. <path
  1081. fill-rule="evenodd"
  1082. 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"
  1083. clip-rule="evenodd"
  1084. />
  1085. </svg>
  1086. </button>
  1087. </div>
  1088. </div>
  1089. <hr class=" dark:border-gray-700" />
  1090. <form
  1091. on:submit|preventDefault={() => {
  1092. uploadModelHandler();
  1093. }}
  1094. >
  1095. <div class=" mb-2 flex w-full justify-between">
  1096. <div class=" text-sm font-medium">
  1097. Upload a GGUF model <a
  1098. class=" text-xs font-medium text-gray-500 underline"
  1099. href="https://github.com/jmorganca/ollama/blob/main/README.md#import-from-gguf"
  1100. target="_blank">(Experimental)</a
  1101. >
  1102. </div>
  1103. <button
  1104. class="p-1 px-3 text-xs flex rounded transition"
  1105. on:click={() => {
  1106. if (modelUploadMode === 'file') {
  1107. modelUploadMode = 'url';
  1108. } else {
  1109. modelUploadMode = 'file';
  1110. }
  1111. }}
  1112. type="button"
  1113. >
  1114. {#if modelUploadMode === 'file'}
  1115. <span class="ml-2 self-center">File Mode</span>
  1116. {:else}
  1117. <span class="ml-2 self-center">URL Mode</span>
  1118. {/if}
  1119. </button>
  1120. </div>
  1121. <div class="flex w-full mb-1.5">
  1122. <div class="flex flex-col w-full">
  1123. {#if modelUploadMode === 'file'}
  1124. <div
  1125. class="flex-1 {modelInputFile && modelInputFile.length > 0 ? 'mr-2' : ''}"
  1126. >
  1127. <input
  1128. id="model-upload-input"
  1129. type="file"
  1130. bind:files={modelInputFile}
  1131. on:change={() => {
  1132. console.log(modelInputFile);
  1133. }}
  1134. accept=".gguf"
  1135. required
  1136. hidden
  1137. />
  1138. <button
  1139. type="button"
  1140. class="w-full rounded text-left py-2 px-4 dark:text-gray-300 dark:bg-gray-800"
  1141. on:click={() => {
  1142. document.getElementById('model-upload-input').click();
  1143. }}
  1144. >
  1145. {#if modelInputFile && modelInputFile.length > 0}
  1146. {modelInputFile[0].name}
  1147. {:else}
  1148. Click here to select
  1149. {/if}
  1150. </button>
  1151. </div>
  1152. {:else}
  1153. <div class="flex-1 {modelFileUrl !== '' ? 'mr-2' : ''}">
  1154. <input
  1155. class="w-full rounded text-left py-2 px-4 dark:text-gray-300 dark:bg-gray-800 outline-none {modelFileUrl !==
  1156. ''
  1157. ? 'mr-2'
  1158. : ''}"
  1159. type="url"
  1160. required
  1161. bind:value={modelFileUrl}
  1162. placeholder="Type HuggingFace Resolve (Download) URL"
  1163. />
  1164. </div>
  1165. {/if}
  1166. </div>
  1167. {#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
  1168. <button
  1169. class="px-3 text-gray-100 bg-emerald-600 hover:bg-emerald-700 disabled:bg-gray-700 disabled:cursor-not-allowed rounded transition"
  1170. type="submit"
  1171. disabled={modelTransferring}
  1172. >
  1173. {#if modelTransferring}
  1174. <div class="self-center">
  1175. <svg
  1176. class=" w-4 h-4"
  1177. viewBox="0 0 24 24"
  1178. fill="currentColor"
  1179. xmlns="http://www.w3.org/2000/svg"
  1180. ><style>
  1181. .spinner_ajPY {
  1182. transform-origin: center;
  1183. animation: spinner_AtaB 0.75s infinite linear;
  1184. }
  1185. @keyframes spinner_AtaB {
  1186. 100% {
  1187. transform: rotate(360deg);
  1188. }
  1189. }
  1190. </style><path
  1191. 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"
  1192. opacity=".25"
  1193. /><path
  1194. 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"
  1195. class="spinner_ajPY"
  1196. /></svg
  1197. >
  1198. </div>
  1199. {:else}
  1200. <svg
  1201. xmlns="http://www.w3.org/2000/svg"
  1202. viewBox="0 0 16 16"
  1203. fill="currentColor"
  1204. class="w-4 h-4"
  1205. >
  1206. <path
  1207. 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"
  1208. />
  1209. <path
  1210. 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"
  1211. />
  1212. </svg>
  1213. {/if}
  1214. </button>
  1215. {/if}
  1216. </div>
  1217. {#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
  1218. <div>
  1219. <div>
  1220. <div class=" my-2.5 text-sm font-medium">Modelfile Content</div>
  1221. <textarea
  1222. bind:value={modelFileContent}
  1223. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
  1224. rows="6"
  1225. />
  1226. </div>
  1227. </div>
  1228. {/if}
  1229. <div class=" mt-1 text-xs text-gray-400 dark:text-gray-500">
  1230. To access the GGUF models available for downloading, <a
  1231. class=" text-gray-500 dark:text-gray-300 font-medium"
  1232. href="https://huggingface.co/models?search=gguf"
  1233. target="_blank">click here.</a
  1234. >
  1235. </div>
  1236. {#if uploadProgress !== null}
  1237. <div class="mt-2">
  1238. <div class=" mb-2 text-xs">Upload Progress</div>
  1239. <div class="w-full rounded-full dark:bg-gray-800">
  1240. <div
  1241. class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
  1242. style="width: {Math.max(15, uploadProgress ?? 0)}%"
  1243. >
  1244. {uploadProgress ?? 0}%
  1245. </div>
  1246. </div>
  1247. <div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
  1248. {modelFileDigest}
  1249. </div>
  1250. </div>
  1251. {/if}
  1252. </form>
  1253. </div>
  1254. </div>
  1255. {:else if selectedTab === 'external'}
  1256. <form
  1257. class="flex flex-col h-full justify-between space-y-3 text-sm"
  1258. on:submit|preventDefault={() => {
  1259. updateOpenAIHandler();
  1260. // saveSettings({
  1261. // OPENAI_API_KEY: OPENAI_API_KEY !== '' ? OPENAI_API_KEY : undefined,
  1262. // OPENAI_API_BASE_URL: OPENAI_API_BASE_URL !== '' ? OPENAI_API_BASE_URL : undefined
  1263. // });
  1264. show = false;
  1265. }}
  1266. >
  1267. <div class=" space-y-3">
  1268. <div>
  1269. <div class=" mb-2.5 text-sm font-medium">OpenAI API Key</div>
  1270. <div class="flex w-full">
  1271. <div class="flex-1">
  1272. <input
  1273. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1274. placeholder="Enter OpenAI API Key"
  1275. bind:value={OPENAI_API_KEY}
  1276. autocomplete="off"
  1277. />
  1278. </div>
  1279. </div>
  1280. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1281. Adds optional support for online models.
  1282. </div>
  1283. </div>
  1284. <hr class=" dark:border-gray-700" />
  1285. <div>
  1286. <div class=" mb-2.5 text-sm font-medium">OpenAI API Base URL</div>
  1287. <div class="flex w-full">
  1288. <div class="flex-1">
  1289. <input
  1290. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1291. placeholder="Enter OpenAI API Key"
  1292. bind:value={OPENAI_API_BASE_URL}
  1293. autocomplete="off"
  1294. />
  1295. </div>
  1296. </div>
  1297. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1298. WebUI will make requests to <span class=" text-gray-200"
  1299. >'{OPENAI_API_BASE_URL}/chat'</span
  1300. >
  1301. </div>
  1302. </div>
  1303. </div>
  1304. <div class="flex justify-end pt-3 text-sm font-medium">
  1305. <button
  1306. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  1307. type="submit"
  1308. >
  1309. Save
  1310. </button>
  1311. </div>
  1312. </form>
  1313. {:else if selectedTab === 'addons'}
  1314. <form
  1315. class="flex flex-col h-full justify-between space-y-3 text-sm"
  1316. on:submit|preventDefault={() => {
  1317. show = false;
  1318. }}
  1319. >
  1320. <div class=" space-y-3">
  1321. <div>
  1322. <div class=" mb-1 text-sm font-medium">WebUI Add-ons</div>
  1323. <div>
  1324. <div class=" py-0.5 flex w-full justify-between">
  1325. <div class=" self-center text-xs font-medium">Title Auto-Generation</div>
  1326. <button
  1327. class="p-1 px-3 text-xs flex rounded transition"
  1328. on:click={() => {
  1329. toggleTitleAutoGenerate();
  1330. }}
  1331. type="button"
  1332. >
  1333. {#if titleAutoGenerate === true}
  1334. <span class="ml-2 self-center">On</span>
  1335. {:else}
  1336. <span class="ml-2 self-center">Off</span>
  1337. {/if}
  1338. </button>
  1339. </div>
  1340. </div>
  1341. <div>
  1342. <div class=" py-0.5 flex w-full justify-between">
  1343. <div class=" self-center text-xs font-medium">Voice Input Auto-Send</div>
  1344. <button
  1345. class="p-1 px-3 text-xs flex rounded transition"
  1346. on:click={() => {
  1347. toggleSpeechAutoSend();
  1348. }}
  1349. type="button"
  1350. >
  1351. {#if speechAutoSend === true}
  1352. <span class="ml-2 self-center">On</span>
  1353. {:else}
  1354. <span class="ml-2 self-center">Off</span>
  1355. {/if}
  1356. </button>
  1357. </div>
  1358. </div>
  1359. <div>
  1360. <div class=" py-0.5 flex w-full justify-between">
  1361. <div class=" self-center text-xs font-medium">
  1362. Response AutoCopy to Clipboard
  1363. </div>
  1364. <button
  1365. class="p-1 px-3 text-xs flex rounded transition"
  1366. on:click={() => {
  1367. toggleResponseAutoCopy();
  1368. }}
  1369. type="button"
  1370. >
  1371. {#if responseAutoCopy === true}
  1372. <span class="ml-2 self-center">On</span>
  1373. {:else}
  1374. <span class="ml-2 self-center">Off</span>
  1375. {/if}
  1376. </button>
  1377. </div>
  1378. </div>
  1379. </div>
  1380. <hr class=" dark:border-gray-700" />
  1381. <div>
  1382. <div class=" mb-2.5 text-sm font-medium">Set Title Auto-Generation Model</div>
  1383. <div class="flex w-full">
  1384. <div class="flex-1 mr-2">
  1385. <select
  1386. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1387. bind:value={titleAutoGenerateModel}
  1388. placeholder="Select a model"
  1389. >
  1390. <option value="" selected>Default</option>
  1391. {#each $models.filter((m) => m.size != null) as model}
  1392. <option value={model.name} class="bg-gray-100 dark:bg-gray-700"
  1393. >{model.name +
  1394. ' (' +
  1395. (model.size / 1024 ** 3).toFixed(1) +
  1396. ' GB)'}</option
  1397. >
  1398. {/each}
  1399. </select>
  1400. </div>
  1401. <button
  1402. 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"
  1403. on:click={() => {
  1404. saveSettings({
  1405. titleAutoGenerateModel:
  1406. titleAutoGenerateModel !== '' ? titleAutoGenerateModel : undefined
  1407. });
  1408. }}
  1409. type="button"
  1410. >
  1411. <svg
  1412. xmlns="http://www.w3.org/2000/svg"
  1413. viewBox="0 0 16 16"
  1414. fill="currentColor"
  1415. class="w-3.5 h-3.5"
  1416. >
  1417. <path
  1418. fill-rule="evenodd"
  1419. 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"
  1420. clip-rule="evenodd"
  1421. />
  1422. </svg>
  1423. </button>
  1424. </div>
  1425. </div>
  1426. <!-- <hr class=" dark:border-gray-700" />
  1427. <div>
  1428. <div class=" mb-2.5 text-sm font-medium">
  1429. Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>
  1430. </div>
  1431. <div class="flex w-full">
  1432. <div class="flex-1">
  1433. <input
  1434. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1435. placeholder="Enter Your Email"
  1436. bind:value={gravatarEmail}
  1437. autocomplete="off"
  1438. type="email"
  1439. />
  1440. </div>
  1441. </div>
  1442. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1443. Changes user profile image to match your <a
  1444. class=" text-gray-500 dark:text-gray-300 font-medium"
  1445. href="https://gravatar.com/"
  1446. target="_blank">Gravatar.</a
  1447. >
  1448. </div>
  1449. </div> -->
  1450. </div>
  1451. <div class="flex justify-end pt-3 text-sm font-medium">
  1452. <button
  1453. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  1454. type="submit"
  1455. >
  1456. Save
  1457. </button>
  1458. </div>
  1459. </form>
  1460. {:else if selectedTab === 'chats'}
  1461. <div class="flex flex-col h-full justify-between space-y-3 text-sm">
  1462. <div class=" space-y-2">
  1463. <div class="flex flex-col">
  1464. <input
  1465. id="chat-import-input"
  1466. bind:files={importFiles}
  1467. type="file"
  1468. accept=".json"
  1469. hidden
  1470. />
  1471. <button
  1472. class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
  1473. on:click={() => {
  1474. document.getElementById('chat-import-input').click();
  1475. }}
  1476. >
  1477. <div class=" self-center mr-3">
  1478. <svg
  1479. xmlns="http://www.w3.org/2000/svg"
  1480. viewBox="0 0 16 16"
  1481. fill="currentColor"
  1482. class="w-4 h-4"
  1483. >
  1484. <path
  1485. fill-rule="evenodd"
  1486. 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"
  1487. clip-rule="evenodd"
  1488. />
  1489. </svg>
  1490. </div>
  1491. <div class=" self-center text-sm font-medium">Import Chats</div>
  1492. </button>
  1493. <button
  1494. class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
  1495. on:click={() => {
  1496. exportChats();
  1497. }}
  1498. >
  1499. <div class=" self-center mr-3">
  1500. <svg
  1501. xmlns="http://www.w3.org/2000/svg"
  1502. viewBox="0 0 16 16"
  1503. fill="currentColor"
  1504. class="w-4 h-4"
  1505. >
  1506. <path
  1507. fill-rule="evenodd"
  1508. 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"
  1509. clip-rule="evenodd"
  1510. />
  1511. </svg>
  1512. </div>
  1513. <div class=" self-center text-sm font-medium">Export Chats</div>
  1514. </button>
  1515. </div>
  1516. <hr class=" dark:border-gray-700" />
  1517. {#if showDeleteConfirm}
  1518. <div
  1519. class="flex justify-between rounded-md items-center py-2 px-3.5 w-full transition"
  1520. >
  1521. <div class="flex items-center space-x-3">
  1522. <svg
  1523. xmlns="http://www.w3.org/2000/svg"
  1524. viewBox="0 0 16 16"
  1525. fill="currentColor"
  1526. class="w-4 h-4"
  1527. >
  1528. <path
  1529. 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"
  1530. />
  1531. <path
  1532. fill-rule="evenodd"
  1533. 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"
  1534. clip-rule="evenodd"
  1535. />
  1536. </svg>
  1537. <span>Are you sure?</span>
  1538. </div>
  1539. <div class="flex space-x-1.5 items-center">
  1540. <button
  1541. class="hover:text-white transition"
  1542. on:click={() => {
  1543. deleteChats();
  1544. showDeleteConfirm = false;
  1545. }}
  1546. >
  1547. <svg
  1548. xmlns="http://www.w3.org/2000/svg"
  1549. viewBox="0 0 20 20"
  1550. fill="currentColor"
  1551. class="w-4 h-4"
  1552. >
  1553. <path
  1554. fill-rule="evenodd"
  1555. 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"
  1556. clip-rule="evenodd"
  1557. />
  1558. </svg>
  1559. </button>
  1560. <button
  1561. class="hover:text-white transition"
  1562. on:click={() => {
  1563. showDeleteConfirm = false;
  1564. }}
  1565. >
  1566. <svg
  1567. xmlns="http://www.w3.org/2000/svg"
  1568. viewBox="0 0 20 20"
  1569. fill="currentColor"
  1570. class="w-4 h-4"
  1571. >
  1572. <path
  1573. 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"
  1574. />
  1575. </svg>
  1576. </button>
  1577. </div>
  1578. </div>
  1579. {:else}
  1580. <button
  1581. class=" flex rounded-md py-2 px-3.5 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
  1582. on:click={() => {
  1583. showDeleteConfirm = true;
  1584. }}
  1585. >
  1586. <div class=" self-center mr-3">
  1587. <svg
  1588. xmlns="http://www.w3.org/2000/svg"
  1589. viewBox="0 0 16 16"
  1590. fill="currentColor"
  1591. class="w-4 h-4"
  1592. >
  1593. <path
  1594. 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"
  1595. />
  1596. <path
  1597. fill-rule="evenodd"
  1598. 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"
  1599. clip-rule="evenodd"
  1600. />
  1601. </svg>
  1602. </div>
  1603. <div class=" self-center text-sm font-medium">Delete All Chats</div>
  1604. </button>
  1605. {/if}
  1606. </div>
  1607. </div>
  1608. {:else if selectedTab === 'auth'}
  1609. <form
  1610. class="flex flex-col h-full justify-between space-y-3 text-sm"
  1611. on:submit|preventDefault={() => {
  1612. console.log('auth save');
  1613. saveSettings({
  1614. authHeader: authEnabled ? `${authType} ${authContent}` : undefined
  1615. });
  1616. show = false;
  1617. }}
  1618. >
  1619. <div class=" space-y-3">
  1620. <div>
  1621. <div class=" py-1 flex w-full justify-between">
  1622. <div class=" self-center text-sm font-medium">Authorization Header</div>
  1623. <button
  1624. class="p-1 px-3 text-xs flex rounded transition"
  1625. type="button"
  1626. on:click={() => {
  1627. toggleAuthHeader();
  1628. }}
  1629. >
  1630. {#if authEnabled === true}
  1631. <svg
  1632. xmlns="http://www.w3.org/2000/svg"
  1633. viewBox="0 0 24 24"
  1634. fill="currentColor"
  1635. class="w-4 h-4"
  1636. >
  1637. <path
  1638. fill-rule="evenodd"
  1639. 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"
  1640. clip-rule="evenodd"
  1641. />
  1642. </svg>
  1643. <span class="ml-2 self-center"> On </span>
  1644. {:else}
  1645. <svg
  1646. xmlns="http://www.w3.org/2000/svg"
  1647. viewBox="0 0 24 24"
  1648. fill="currentColor"
  1649. class="w-4 h-4"
  1650. >
  1651. <path
  1652. 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"
  1653. />
  1654. </svg>
  1655. <span class="ml-2 self-center">Off</span>
  1656. {/if}
  1657. </button>
  1658. </div>
  1659. </div>
  1660. {#if authEnabled}
  1661. <hr class=" dark:border-gray-700" />
  1662. <div class="mt-2">
  1663. <div class=" py-1 flex w-full space-x-2">
  1664. <button
  1665. class=" py-1 font-semibold flex rounded transition"
  1666. on:click={() => {
  1667. authType = authType === 'Basic' ? 'Bearer' : 'Basic';
  1668. }}
  1669. type="button"
  1670. >
  1671. {#if authType === 'Basic'}
  1672. <span class="self-center mr-2">Basic</span>
  1673. {:else if authType === 'Bearer'}
  1674. <span class="self-center mr-2">Bearer</span>
  1675. {/if}
  1676. </button>
  1677. <div class="flex-1">
  1678. <input
  1679. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1680. placeholder="Enter Authorization Header Content"
  1681. bind:value={authContent}
  1682. />
  1683. </div>
  1684. </div>
  1685. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1686. Toggle between <span class=" text-gray-500 dark:text-gray-300 font-medium"
  1687. >'Basic'</span
  1688. >
  1689. and <span class=" text-gray-500 dark:text-gray-300 font-medium">'Bearer'</span> by
  1690. clicking on the label next to the input.
  1691. </div>
  1692. </div>
  1693. <hr class=" dark:border-gray-700" />
  1694. <div>
  1695. <div class=" mb-2.5 text-sm font-medium">Preview Authorization Header</div>
  1696. <textarea
  1697. value={JSON.stringify({
  1698. Authorization: `${authType} ${authContent}`
  1699. })}
  1700. class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
  1701. rows="2"
  1702. disabled
  1703. />
  1704. </div>
  1705. {/if}
  1706. </div>
  1707. <div class="flex justify-end pt-3 text-sm font-medium">
  1708. <button
  1709. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  1710. type="submit"
  1711. >
  1712. Save
  1713. </button>
  1714. </div>
  1715. </form>
  1716. {:else if selectedTab === 'account'}
  1717. <form
  1718. class="flex flex-col h-full text-sm"
  1719. on:submit|preventDefault={() => {
  1720. updatePasswordHandler();
  1721. }}
  1722. >
  1723. <div class=" mb-2.5 font-medium">Change Password</div>
  1724. <div class=" space-y-1.5">
  1725. <div class="flex flex-col w-full">
  1726. <div class=" mb-1 text-xs text-gray-500">Current Password</div>
  1727. <div class="flex-1">
  1728. <input
  1729. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1730. type="password"
  1731. bind:value={currentPassword}
  1732. autocomplete="current-password"
  1733. required
  1734. />
  1735. </div>
  1736. </div>
  1737. <div class="flex flex-col w-full">
  1738. <div class=" mb-1 text-xs text-gray-500">New Password</div>
  1739. <div class="flex-1">
  1740. <input
  1741. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1742. type="password"
  1743. bind:value={newPassword}
  1744. autocomplete="new-password"
  1745. required
  1746. />
  1747. </div>
  1748. </div>
  1749. <div class="flex flex-col w-full">
  1750. <div class=" mb-1 text-xs text-gray-500">Confirm Password</div>
  1751. <div class="flex-1">
  1752. <input
  1753. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1754. type="password"
  1755. bind:value={newPasswordConfirm}
  1756. autocomplete="off"
  1757. required
  1758. />
  1759. </div>
  1760. </div>
  1761. </div>
  1762. <div class="mt-3 flex justify-end">
  1763. <button
  1764. class=" px-4 py-2 text-xs bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-800 text-gray-100 transition rounded-md font-medium"
  1765. >
  1766. Update password
  1767. </button>
  1768. </div>
  1769. </form>
  1770. {:else if selectedTab === 'about'}
  1771. <div class="flex flex-col h-full justify-between space-y-3 text-sm mb-6">
  1772. <div class=" space-y-3">
  1773. <div>
  1774. <div class=" mb-2.5 text-sm font-medium">Ollama Web UI Version</div>
  1775. <div class="flex w-full">
  1776. <div class="flex-1 text-xs text-gray-700 dark:text-gray-200">
  1777. {$config && $config.version ? $config.version : WEB_UI_VERSION}
  1778. </div>
  1779. </div>
  1780. </div>
  1781. <hr class=" dark:border-gray-700" />
  1782. <div>
  1783. <div class=" mb-2.5 text-sm font-medium">Ollama Version</div>
  1784. <div class="flex w-full">
  1785. <div class="flex-1 text-xs text-gray-700 dark:text-gray-200">
  1786. {ollamaVersion ?? 'N/A'}
  1787. </div>
  1788. </div>
  1789. </div>
  1790. <hr class=" dark:border-gray-700" />
  1791. <div class="flex space-x-1">
  1792. <a href="https://discord.gg/5rJgQTnV4s" target="_blank">
  1793. <img
  1794. alt="Discord"
  1795. src="https://img.shields.io/badge/Discord-Ollama_Web_UI-blue?logo=discord&logoColor=white"
  1796. />
  1797. </a>
  1798. <a href="https://github.com/ollama-webui/ollama-webui" target="_blank">
  1799. <img
  1800. alt="Github Repo"
  1801. src="https://img.shields.io/github/stars/ollama-webui/ollama-webui?style=social&label=Star us on Github"
  1802. />
  1803. </a>
  1804. </div>
  1805. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1806. Created by <a
  1807. class=" text-gray-500 dark:text-gray-300 font-medium"
  1808. href="https://github.com/tjbck"
  1809. target="_blank">Timothy J. Baek</a
  1810. >
  1811. </div>
  1812. </div>
  1813. </div>
  1814. {/if}
  1815. </div>
  1816. </div>
  1817. </div>
  1818. </Modal>
  1819. <style>
  1820. input::-webkit-outer-spin-button,
  1821. input::-webkit-inner-spin-button {
  1822. /* display: none; <- Crashes Chrome on hover */
  1823. -webkit-appearance: none;
  1824. margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
  1825. }
  1826. .tabs::-webkit-scrollbar {
  1827. display: none; /* for Chrome, Safari and Opera */
  1828. }
  1829. .tabs {
  1830. -ms-overflow-style: none; /* IE and Edge */
  1831. scrollbar-width: none; /* Firefox */
  1832. }
  1833. input[type='number'] {
  1834. -moz-appearance: textfield; /* Firefox */
  1835. }
  1836. </style>