SettingsModal.svelte 64 KB

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