SettingsModal.svelte 60 KB

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