SettingsModal.svelte 68 KB

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