SettingsModal.svelte 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. <script lang="ts">
  2. import Modal from '../common/Modal.svelte';
  3. import { WEB_UI_VERSION, OLLAMA_API_BASE_URL } from '$lib/constants';
  4. import toast from 'svelte-french-toast';
  5. import { onMount } from 'svelte';
  6. import { config, models, settings, user } from '$lib/stores';
  7. import { splitStream, getGravatarURL } from '$lib/utils';
  8. export let show = false;
  9. const saveSettings = async (updated) => {
  10. console.log(updated);
  11. await settings.set({ ...$settings, ...updated });
  12. await models.set(await getModels());
  13. localStorage.setItem('settings', JSON.stringify($settings));
  14. };
  15. let selectedTab = 'general';
  16. // General
  17. let API_BASE_URL = OLLAMA_API_BASE_URL;
  18. let theme = 'dark';
  19. let system = '';
  20. // Advanced
  21. let requestFormat = '';
  22. let seed = 0;
  23. let temperature = '';
  24. let repeat_penalty = '';
  25. let top_k = '';
  26. let top_p = '';
  27. let num_ctx = '';
  28. // Models
  29. let modelTag = '';
  30. let deleteModelTag = '';
  31. let digest = '';
  32. let pullProgress = null;
  33. // Addons
  34. let titleAutoGenerate = true;
  35. let speechAutoSend = false;
  36. let gravatarEmail = '';
  37. let OPENAI_API_KEY = '';
  38. // Auth
  39. let authEnabled = false;
  40. let authType = 'Basic';
  41. let authContent = '';
  42. const checkOllamaConnection = async () => {
  43. if (API_BASE_URL === '') {
  44. API_BASE_URL = OLLAMA_API_BASE_URL;
  45. }
  46. const _models = await getModels(API_BASE_URL, 'ollama');
  47. if (_models.length > 0) {
  48. toast.success('Server connection verified');
  49. await models.set(_models);
  50. saveSettings({
  51. API_BASE_URL: API_BASE_URL
  52. });
  53. }
  54. };
  55. const toggleTheme = async () => {
  56. if (theme === 'dark') {
  57. theme = 'light';
  58. } else {
  59. theme = 'dark';
  60. }
  61. localStorage.theme = theme;
  62. document.documentElement.classList.remove(theme === 'dark' ? 'light' : 'dark');
  63. document.documentElement.classList.add(theme);
  64. };
  65. const toggleRequestFormat = async () => {
  66. if (requestFormat === '') {
  67. requestFormat = 'json';
  68. } else {
  69. requestFormat = '';
  70. }
  71. saveSettings({ requestFormat: requestFormat !== '' ? requestFormat : undefined });
  72. };
  73. const toggleSpeechAutoSend = async () => {
  74. speechAutoSend = !speechAutoSend;
  75. saveSettings({ speechAutoSend: speechAutoSend });
  76. };
  77. const toggleTitleAutoGenerate = async () => {
  78. titleAutoGenerate = !titleAutoGenerate;
  79. saveSettings({ titleAutoGenerate: titleAutoGenerate });
  80. };
  81. const toggleAuthHeader = async () => {
  82. authEnabled = !authEnabled;
  83. };
  84. const pullModelHandler = async () => {
  85. const res = await fetch(`${API_BASE_URL}/pull`, {
  86. method: 'POST',
  87. headers: {
  88. 'Content-Type': 'text/event-stream',
  89. ...($settings.authHeader && { Authorization: $settings.authHeader }),
  90. ...($user && { Authorization: `Bearer ${localStorage.token}` })
  91. },
  92. body: JSON.stringify({
  93. name: modelTag
  94. })
  95. });
  96. const reader = res.body
  97. .pipeThrough(new TextDecoderStream())
  98. .pipeThrough(splitStream('\n'))
  99. .getReader();
  100. while (true) {
  101. const { value, done } = await reader.read();
  102. if (done) break;
  103. try {
  104. let lines = value.split('\n');
  105. for (const line of lines) {
  106. if (line !== '') {
  107. console.log(line);
  108. let data = JSON.parse(line);
  109. console.log(data);
  110. if (data.error) {
  111. throw data.error;
  112. }
  113. if (data.detail) {
  114. throw data.detail;
  115. }
  116. if (data.status) {
  117. if (!data.digest) {
  118. toast.success(data.status);
  119. } else {
  120. digest = data.digest;
  121. if (data.completed) {
  122. pullProgress = Math.round((data.completed / data.total) * 1000) / 10;
  123. } else {
  124. pullProgress = 100;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. } catch (error) {
  131. console.log(error);
  132. toast.error(error);
  133. }
  134. }
  135. modelTag = '';
  136. models.set(await getModels());
  137. };
  138. const deleteModelHandler = async () => {
  139. const res = await fetch(`${API_BASE_URL}/delete`, {
  140. method: 'DELETE',
  141. headers: {
  142. 'Content-Type': 'text/event-stream',
  143. ...($settings.authHeader && { Authorization: $settings.authHeader }),
  144. ...($user && { Authorization: `Bearer ${localStorage.token}` })
  145. },
  146. body: JSON.stringify({
  147. name: deleteModelTag
  148. })
  149. });
  150. const reader = res.body
  151. .pipeThrough(new TextDecoderStream())
  152. .pipeThrough(splitStream('\n'))
  153. .getReader();
  154. while (true) {
  155. const { value, done } = await reader.read();
  156. if (done) break;
  157. try {
  158. let lines = value.split('\n');
  159. for (const line of lines) {
  160. if (line !== '' && line !== 'null') {
  161. console.log(line);
  162. let data = JSON.parse(line);
  163. console.log(data);
  164. if (data.error) {
  165. throw data.error;
  166. }
  167. if (data.detail) {
  168. throw data.detail;
  169. }
  170. if (data.status) {
  171. }
  172. } else {
  173. toast.success(`Deleted ${deleteModelTag}`);
  174. }
  175. }
  176. } catch (error) {
  177. console.log(error);
  178. toast.error(error);
  179. }
  180. }
  181. deleteModelTag = '';
  182. models.set(await getModels());
  183. };
  184. $: if (show) {
  185. let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
  186. console.log(settings);
  187. theme = localStorage.theme ?? 'dark';
  188. API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL;
  189. system = settings.system ?? '';
  190. requestFormat = settings.requestFormat ?? '';
  191. seed = settings.seed ?? 0;
  192. temperature = settings.temperature ?? '';
  193. repeat_penalty = settings.repeat_penalty ?? '';
  194. top_k = settings.top_k ?? '';
  195. top_p = settings.top_p ?? '';
  196. num_ctx = settings.num_ctx ?? '';
  197. titleAutoGenerate = settings.titleAutoGenerate ?? true;
  198. speechAutoSend = settings.speechAutoSend ?? false;
  199. gravatarEmail = settings.gravatarEmail ?? '';
  200. OPENAI_API_KEY = settings.OPENAI_API_KEY ?? '';
  201. }
  202. const getModels = async (url = '', type = 'all') => {
  203. let models = [];
  204. const res = await fetch(`${url ? url : $settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/tags`, {
  205. method: 'GET',
  206. headers: {
  207. Accept: 'application/json',
  208. 'Content-Type': 'application/json',
  209. ...($settings.authHeader && { Authorization: $settings.authHeader }),
  210. ...($user && { Authorization: `Bearer ${localStorage.token}` })
  211. }
  212. })
  213. .then(async (res) => {
  214. if (!res.ok) throw await res.json();
  215. return res.json();
  216. })
  217. .catch((error) => {
  218. console.log(error);
  219. if ('detail' in error) {
  220. toast.error(error.detail);
  221. } else {
  222. toast.error('Server connection failed');
  223. }
  224. return null;
  225. });
  226. console.log(res);
  227. models.push(...(res?.models ?? []));
  228. // If OpenAI API Key exists
  229. if (type === 'all' && $settings.OPENAI_API_KEY) {
  230. // Validate OPENAI_API_KEY
  231. const openaiModelRes = await fetch(`https://api.openai.com/v1/models`, {
  232. method: 'GET',
  233. headers: {
  234. 'Content-Type': 'application/json',
  235. Authorization: `Bearer ${$settings.OPENAI_API_KEY}`
  236. }
  237. })
  238. .then(async (res) => {
  239. if (!res.ok) throw await res.json();
  240. return res.json();
  241. })
  242. .catch((error) => {
  243. console.log(error);
  244. toast.error(`OpenAI: ${error?.error?.message ?? 'Network Problem'}`);
  245. return null;
  246. });
  247. const openAIModels = openaiModelRes?.data ?? null;
  248. models.push(
  249. ...(openAIModels
  250. ? [
  251. { name: 'hr' },
  252. ...openAIModels
  253. .map((model) => ({ name: model.id, label: 'OpenAI' }))
  254. .filter((model) => model.name.includes('gpt'))
  255. ]
  256. : [])
  257. );
  258. }
  259. return models;
  260. };
  261. onMount(() => {
  262. let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
  263. authEnabled = settings.authHeader !== undefined ? true : false;
  264. if (authEnabled) {
  265. authType = settings.authHeader.split(' ')[0];
  266. authContent = settings.authHeader.split(' ')[1];
  267. }
  268. });
  269. </script>
  270. <Modal bind:show>
  271. <div>
  272. <div class=" flex justify-between dark:text-gray-300 px-5 py-4">
  273. <div class=" text-lg font-medium self-center">Settings</div>
  274. <button
  275. class="self-center"
  276. on:click={() => {
  277. show = false;
  278. }}
  279. >
  280. <svg
  281. xmlns="http://www.w3.org/2000/svg"
  282. viewBox="0 0 20 20"
  283. fill="currentColor"
  284. class="w-5 h-5"
  285. >
  286. <path
  287. 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"
  288. />
  289. </svg>
  290. </button>
  291. </div>
  292. <hr class=" dark:border-gray-800" />
  293. <div class="flex flex-col md:flex-row w-full p-4 md:space-x-4">
  294. <div
  295. 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"
  296. >
  297. <button
  298. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  299. 'general'
  300. ? 'bg-gray-200 dark:bg-gray-700'
  301. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  302. on:click={() => {
  303. selectedTab = 'general';
  304. }}
  305. >
  306. <div class=" self-center mr-2">
  307. <svg
  308. xmlns="http://www.w3.org/2000/svg"
  309. viewBox="0 0 20 20"
  310. fill="currentColor"
  311. class="w-4 h-4"
  312. >
  313. <path
  314. fill-rule="evenodd"
  315. 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"
  316. clip-rule="evenodd"
  317. />
  318. </svg>
  319. </div>
  320. <div class=" self-center">General</div>
  321. </button>
  322. <button
  323. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  324. 'advanced'
  325. ? 'bg-gray-200 dark:bg-gray-700'
  326. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  327. on:click={() => {
  328. selectedTab = 'advanced';
  329. }}
  330. >
  331. <div class=" self-center mr-2">
  332. <svg
  333. xmlns="http://www.w3.org/2000/svg"
  334. viewBox="0 0 20 20"
  335. fill="currentColor"
  336. class="w-4 h-4"
  337. >
  338. <path
  339. 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"
  340. />
  341. </svg>
  342. </div>
  343. <div class=" self-center">Advanced</div>
  344. </button>
  345. <button
  346. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  347. 'models'
  348. ? 'bg-gray-200 dark:bg-gray-700'
  349. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  350. on:click={() => {
  351. selectedTab = 'models';
  352. }}
  353. >
  354. <div class=" self-center mr-2">
  355. <svg
  356. xmlns="http://www.w3.org/2000/svg"
  357. viewBox="0 0 20 20"
  358. fill="currentColor"
  359. class="w-4 h-4"
  360. >
  361. <path
  362. fill-rule="evenodd"
  363. 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"
  364. clip-rule="evenodd"
  365. />
  366. </svg>
  367. </div>
  368. <div class=" self-center">Models</div>
  369. </button>
  370. <button
  371. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  372. 'addons'
  373. ? 'bg-gray-200 dark:bg-gray-700'
  374. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  375. on:click={() => {
  376. selectedTab = 'addons';
  377. }}
  378. >
  379. <div class=" self-center mr-2">
  380. <svg
  381. xmlns="http://www.w3.org/2000/svg"
  382. viewBox="0 0 20 20"
  383. fill="currentColor"
  384. class="w-4 h-4"
  385. >
  386. <path
  387. 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"
  388. />
  389. </svg>
  390. </div>
  391. <div class=" self-center">Add-ons</div>
  392. </button>
  393. {#if !$config || ($config && !$config.auth)}
  394. <button
  395. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  396. 'auth'
  397. ? 'bg-gray-200 dark:bg-gray-700'
  398. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  399. on:click={() => {
  400. selectedTab = 'auth';
  401. }}
  402. >
  403. <div class=" self-center mr-2">
  404. <svg
  405. xmlns="http://www.w3.org/2000/svg"
  406. viewBox="0 0 24 24"
  407. fill="currentColor"
  408. class="w-4 h-4"
  409. >
  410. <path
  411. fill-rule="evenodd"
  412. 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"
  413. clip-rule="evenodd"
  414. />
  415. </svg>
  416. </div>
  417. <div class=" self-center">Authentication</div>
  418. </button>
  419. {/if}
  420. <button
  421. class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
  422. 'about'
  423. ? 'bg-gray-200 dark:bg-gray-700'
  424. : ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
  425. on:click={() => {
  426. selectedTab = 'about';
  427. }}
  428. >
  429. <div class=" self-center mr-2">
  430. <svg
  431. xmlns="http://www.w3.org/2000/svg"
  432. viewBox="0 0 20 20"
  433. fill="currentColor"
  434. class="w-4 h-4"
  435. >
  436. <path
  437. fill-rule="evenodd"
  438. 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"
  439. clip-rule="evenodd"
  440. />
  441. </svg>
  442. </div>
  443. <div class=" self-center">About</div>
  444. </button>
  445. </div>
  446. <div class="flex-1 md:min-h-[330px]">
  447. {#if selectedTab === 'general'}
  448. <div class="flex flex-col space-y-3">
  449. <div>
  450. <div class=" py-1 flex w-full justify-between">
  451. <div class=" self-center text-sm font-medium">Theme</div>
  452. <button
  453. class="p-1 px-3 text-xs flex rounded transition"
  454. on:click={() => {
  455. toggleTheme();
  456. }}
  457. >
  458. {#if theme === 'dark'}
  459. <svg
  460. xmlns="http://www.w3.org/2000/svg"
  461. viewBox="0 0 20 20"
  462. fill="currentColor"
  463. class="w-4 h-4"
  464. >
  465. <path
  466. fill-rule="evenodd"
  467. 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"
  468. clip-rule="evenodd"
  469. />
  470. </svg>
  471. <span class="ml-2 self-center"> Dark </span>
  472. {:else}
  473. <svg
  474. xmlns="http://www.w3.org/2000/svg"
  475. viewBox="0 0 20 20"
  476. fill="currentColor"
  477. class="w-4 h-4 self-center"
  478. >
  479. <path
  480. 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"
  481. />
  482. </svg>
  483. <span class="ml-2 self-center"> Light </span>
  484. {/if}
  485. </button>
  486. </div>
  487. </div>
  488. <hr class=" dark:border-gray-700" />
  489. <div>
  490. <div class=" mb-2.5 text-sm font-medium">Ollama Server URL</div>
  491. <div class="flex w-full">
  492. <div class="flex-1 mr-2">
  493. <input
  494. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  495. placeholder="Enter URL (e.g. http://localhost:11434/api)"
  496. bind:value={API_BASE_URL}
  497. />
  498. </div>
  499. <button
  500. class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 rounded transition"
  501. on:click={() => {
  502. checkOllamaConnection();
  503. }}
  504. >
  505. <svg
  506. xmlns="http://www.w3.org/2000/svg"
  507. viewBox="0 0 20 20"
  508. fill="currentColor"
  509. class="w-4 h-4"
  510. >
  511. <path
  512. fill-rule="evenodd"
  513. 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"
  514. clip-rule="evenodd"
  515. />
  516. </svg>
  517. </button>
  518. </div>
  519. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  520. Trouble accessing Ollama? <a
  521. class=" text-gray-500 dark:text-gray-300 font-medium"
  522. href="https://github.com/ollama-webui/ollama-webui#troubleshooting"
  523. target="_blank"
  524. >
  525. Click here for help.
  526. </a>
  527. </div>
  528. </div>
  529. <hr class=" dark:border-gray-700" />
  530. <div>
  531. <div class=" mb-2.5 text-sm font-medium">System Prompt</div>
  532. <textarea
  533. bind:value={system}
  534. class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
  535. rows="4"
  536. />
  537. </div>
  538. <div class="flex justify-end pt-3 text-sm font-medium">
  539. <button
  540. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  541. on:click={() => {
  542. saveSettings({
  543. API_BASE_URL: API_BASE_URL === '' ? OLLAMA_API_BASE_URL : API_BASE_URL,
  544. system: system !== '' ? system : undefined
  545. });
  546. show = false;
  547. }}
  548. >
  549. Save
  550. </button>
  551. </div>
  552. </div>
  553. {:else if selectedTab === 'advanced'}
  554. <div class="flex flex-col h-full justify-between space-y-3 text-sm">
  555. <div class=" space-y-3">
  556. <div>
  557. <div class=" py-1 flex w-full justify-between">
  558. <div class=" w-20 text-sm font-medium self-center">Seed</div>
  559. <div class=" flex-1 self-center">
  560. <input
  561. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  562. type="number"
  563. placeholder="Enter Seed"
  564. bind:value={seed}
  565. autocomplete="off"
  566. min="0"
  567. />
  568. </div>
  569. </div>
  570. </div>
  571. <div class=" py-0.5 w-full justify-between">
  572. <div class="flex w-full justify-between">
  573. <div class=" self-center text-sm font-medium">Temperature</div>
  574. <button
  575. class="p-1 px-3 text-xs flex rounded transition"
  576. on:click={() => {
  577. temperature = temperature === '' ? 0.8 : '';
  578. }}
  579. >
  580. {#if temperature === ''}
  581. <span class="ml-2 self-center"> Default </span>
  582. {:else}
  583. <span class="ml-2 self-center"> Custom </span>
  584. {/if}
  585. </button>
  586. </div>
  587. {#if temperature !== ''}
  588. <div class="flex mt-0.5 space-x-2">
  589. <div class=" flex-1">
  590. <input
  591. id="steps-range"
  592. type="range"
  593. min="0"
  594. max="1"
  595. bind:value={temperature}
  596. step="0.05"
  597. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  598. />
  599. </div>
  600. <div>
  601. <input
  602. bind:value={temperature}
  603. type="number"
  604. class=" bg-transparent text-center w-10"
  605. />
  606. </div>
  607. </div>
  608. {/if}
  609. </div>
  610. <div class=" py-0.5 w-full justify-between">
  611. <div class="flex w-full justify-between">
  612. <div class=" self-center text-sm font-medium">Repeat Penalty</div>
  613. <button
  614. class="p-1 px-3 text-xs flex rounded transition"
  615. on:click={() => {
  616. repeat_penalty = repeat_penalty === '' ? 1.1 : '';
  617. }}
  618. >
  619. {#if repeat_penalty === ''}
  620. <span class="ml-2 self-center"> Default </span>
  621. {:else}
  622. <span class="ml-2 self-center"> Custom </span>
  623. {/if}
  624. </button>
  625. </div>
  626. {#if repeat_penalty !== ''}
  627. <div class="flex mt-0.5 space-x-2">
  628. <div class=" flex-1">
  629. <input
  630. id="steps-range"
  631. type="range"
  632. min="0"
  633. max="2"
  634. bind:value={repeat_penalty}
  635. step="0.05"
  636. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  637. />
  638. </div>
  639. <div>
  640. <input
  641. bind:value={repeat_penalty}
  642. type="number"
  643. class=" bg-transparent text-center w-10"
  644. />
  645. </div>
  646. </div>
  647. {/if}
  648. </div>
  649. <div class=" py-0.5 w-full justify-between">
  650. <div class="flex w-full justify-between">
  651. <div class=" self-center text-sm font-medium">Top K</div>
  652. <button
  653. class="p-1 px-3 text-xs flex rounded transition"
  654. on:click={() => {
  655. top_k = top_k === '' ? 40 : '';
  656. }}
  657. >
  658. {#if top_k === ''}
  659. <span class="ml-2 self-center"> Default </span>
  660. {:else}
  661. <span class="ml-2 self-center"> Custom </span>
  662. {/if}
  663. </button>
  664. </div>
  665. {#if top_k !== ''}
  666. <div class="flex mt-0.5 space-x-2">
  667. <div class=" flex-1">
  668. <input
  669. id="steps-range"
  670. type="range"
  671. min="0"
  672. max="100"
  673. bind:value={top_k}
  674. step="0.5"
  675. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  676. />
  677. </div>
  678. <div>
  679. <input
  680. bind:value={top_k}
  681. type="number"
  682. class=" bg-transparent text-center w-10"
  683. />
  684. </div>
  685. </div>
  686. {/if}
  687. </div>
  688. <div class=" py-0.5 w-full justify-between">
  689. <div class="flex w-full justify-between">
  690. <div class=" self-center text-sm font-medium">Top P</div>
  691. <button
  692. class="p-1 px-3 text-xs flex rounded transition"
  693. on:click={() => {
  694. top_p = top_p === '' ? 0.9 : '';
  695. }}
  696. >
  697. {#if top_p === ''}
  698. <span class="ml-2 self-center"> Default </span>
  699. {:else}
  700. <span class="ml-2 self-center"> Custom </span>
  701. {/if}
  702. </button>
  703. </div>
  704. {#if top_p !== ''}
  705. <div class="flex mt-0.5 space-x-2">
  706. <div class=" flex-1">
  707. <input
  708. id="steps-range"
  709. type="range"
  710. min="0"
  711. max="1"
  712. bind:value={top_p}
  713. step="0.05"
  714. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  715. />
  716. </div>
  717. <div>
  718. <input
  719. bind:value={top_p}
  720. type="number"
  721. class=" bg-transparent text-center w-10"
  722. />
  723. </div>
  724. </div>
  725. {/if}
  726. </div>
  727. <div class=" py-0.5 w-full justify-between">
  728. <div class="flex w-full justify-between">
  729. <div class=" self-center text-sm font-medium">Context Length</div>
  730. <button
  731. class="p-1 px-3 text-xs flex rounded transition"
  732. on:click={() => {
  733. num_ctx = num_ctx === '' ? 2048 : '';
  734. }}
  735. >
  736. {#if num_ctx === ''}
  737. <span class="ml-2 self-center"> Default </span>
  738. {:else}
  739. <span class="ml-2 self-center"> Custom </span>
  740. {/if}
  741. </button>
  742. </div>
  743. {#if num_ctx !== ''}
  744. <div class="flex mt-0.5 space-x-2">
  745. <div class=" flex-1">
  746. <input
  747. id="steps-range"
  748. type="range"
  749. min="1"
  750. max="16000"
  751. bind:value={num_ctx}
  752. step="1"
  753. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  754. />
  755. </div>
  756. <div>
  757. <input
  758. bind:value={num_ctx}
  759. type="number"
  760. class=" bg-transparent text-center w-10"
  761. />
  762. </div>
  763. </div>
  764. {/if}
  765. </div>
  766. <hr class=" dark:border-gray-700" />
  767. <div>
  768. <div class=" py-1 flex w-full justify-between">
  769. <div class=" self-center text-sm font-medium">Request Mode</div>
  770. <button
  771. class="p-1 px-3 text-xs flex rounded transition"
  772. on:click={() => {
  773. toggleRequestFormat();
  774. }}
  775. >
  776. {#if requestFormat === ''}
  777. <span class="ml-2 self-center"> Default </span>
  778. {:else if requestFormat === 'json'}
  779. <!-- <svg
  780. xmlns="http://www.w3.org/2000/svg"
  781. viewBox="0 0 20 20"
  782. fill="currentColor"
  783. class="w-4 h-4 self-center"
  784. >
  785. <path
  786. 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"
  787. />
  788. </svg> -->
  789. <span class="ml-2 self-center"> JSON </span>
  790. {/if}
  791. </button>
  792. </div>
  793. </div>
  794. </div>
  795. <div class="flex justify-end pt-3 text-sm font-medium">
  796. <button
  797. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  798. on:click={() => {
  799. saveSettings({
  800. seed: (seed !== 0 ? seed : undefined) ?? undefined,
  801. temperature: temperature !== '' ? temperature : undefined,
  802. repeat_penalty: repeat_penalty !== '' ? repeat_penalty : undefined,
  803. top_k: top_k !== '' ? top_k : undefined,
  804. top_p: top_p !== '' ? top_p : undefined,
  805. num_ctx: num_ctx !== '' ? num_ctx : undefined
  806. });
  807. show = false;
  808. }}
  809. >
  810. Save
  811. </button>
  812. </div>
  813. </div>
  814. {:else if selectedTab === 'models'}
  815. <div class="flex flex-col space-y-3 text-sm mb-10">
  816. <div>
  817. <div class=" mb-2.5 text-sm font-medium">Pull a model</div>
  818. <div class="flex w-full">
  819. <div class="flex-1 mr-2">
  820. <input
  821. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  822. placeholder="Enter model tag (e.g. mistral:7b)"
  823. bind:value={modelTag}
  824. />
  825. </div>
  826. <button
  827. class="px-3 text-gray-100 bg-emerald-600 hover:bg-emerald-700 rounded transition"
  828. on:click={() => {
  829. pullModelHandler();
  830. }}
  831. >
  832. <svg
  833. xmlns="http://www.w3.org/2000/svg"
  834. viewBox="0 0 20 20"
  835. fill="currentColor"
  836. class="w-4 h-4"
  837. >
  838. <path
  839. d="M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"
  840. />
  841. <path
  842. d="M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"
  843. />
  844. </svg>
  845. </button>
  846. </div>
  847. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  848. To access the available model names for downloading, <a
  849. class=" text-gray-500 dark:text-gray-300 font-medium"
  850. href="https://ollama.ai/library"
  851. target="_blank">click here.</a
  852. >
  853. </div>
  854. {#if pullProgress !== null}
  855. <div class="mt-2">
  856. <div class=" mb-2 text-xs">Pull Progress</div>
  857. <div class="w-full rounded-full dark:bg-gray-800">
  858. <div
  859. class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
  860. style="width: {Math.max(15, pullProgress ?? 0)}%"
  861. >
  862. {pullProgress ?? 0}%
  863. </div>
  864. </div>
  865. <div class="mt-1 text-xs dark:text-gray-700" style="font-size: 0.5rem;">
  866. {digest}
  867. </div>
  868. </div>
  869. {/if}
  870. </div>
  871. <hr class=" dark:border-gray-700" />
  872. <div>
  873. <div class=" mb-2.5 text-sm font-medium">Delete a model</div>
  874. <div class="flex w-full">
  875. <div class="flex-1 mr-2">
  876. <input
  877. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  878. placeholder="Enter model tag (e.g. mistral:7b)"
  879. bind:value={deleteModelTag}
  880. />
  881. </div>
  882. <button
  883. class="px-3 bg-red-700 hover:bg-red-800 text-gray-100 rounded transition"
  884. on:click={() => {
  885. deleteModelHandler();
  886. }}
  887. >
  888. <svg
  889. xmlns="http://www.w3.org/2000/svg"
  890. viewBox="0 0 20 20"
  891. fill="currentColor"
  892. class="w-4 h-4"
  893. >
  894. <path
  895. fill-rule="evenodd"
  896. d="M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.52.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z"
  897. clip-rule="evenodd"
  898. />
  899. </svg>
  900. </button>
  901. </div>
  902. </div>
  903. </div>
  904. {:else if selectedTab === 'addons'}
  905. <form
  906. class="flex flex-col h-full justify-between space-y-3 text-sm"
  907. on:submit|preventDefault={() => {
  908. saveSettings({
  909. gravatarEmail: gravatarEmail !== '' ? gravatarEmail : undefined,
  910. gravatarUrl: gravatarEmail !== '' ? getGravatarURL(gravatarEmail) : undefined,
  911. OPENAI_API_KEY: OPENAI_API_KEY !== '' ? OPENAI_API_KEY : undefined
  912. });
  913. show = false;
  914. }}
  915. >
  916. <div class=" space-y-3">
  917. <div>
  918. <div class=" py-1 flex w-full justify-between">
  919. <div class=" self-center text-sm font-medium">Title Auto Generation</div>
  920. <button
  921. class="p-1 px-3 text-xs flex rounded transition"
  922. on:click={() => {
  923. toggleTitleAutoGenerate();
  924. }}
  925. type="button"
  926. >
  927. {#if titleAutoGenerate === true}
  928. <span class="ml-2 self-center">On</span>
  929. {:else}
  930. <span class="ml-2 self-center">Off</span>
  931. {/if}
  932. </button>
  933. </div>
  934. </div>
  935. <hr class=" dark:border-gray-700" />
  936. <div>
  937. <div class=" py-1 flex w-full justify-between">
  938. <div class=" self-center text-sm font-medium">Voice Input Auto-Send</div>
  939. <button
  940. class="p-1 px-3 text-xs flex rounded transition"
  941. on:click={() => {
  942. toggleSpeechAutoSend();
  943. }}
  944. type="button"
  945. >
  946. {#if speechAutoSend === true}
  947. <span class="ml-2 self-center">On</span>
  948. {:else}
  949. <span class="ml-2 self-center">Off</span>
  950. {/if}
  951. </button>
  952. </div>
  953. </div>
  954. <hr class=" dark:border-gray-700" />
  955. <div>
  956. <div class=" mb-2.5 text-sm font-medium">
  957. Gravatar Email <span class=" text-gray-400 text-sm">(optional)</span>
  958. </div>
  959. <div class="flex w-full">
  960. <div class="flex-1">
  961. <input
  962. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  963. placeholder="Enter Your Email"
  964. bind:value={gravatarEmail}
  965. autocomplete="off"
  966. type="email"
  967. />
  968. </div>
  969. </div>
  970. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  971. Changes user profile image to match your <a
  972. class=" text-gray-500 dark:text-gray-300 font-medium"
  973. href="https://gravatar.com/"
  974. target="_blank">Gravatar.</a
  975. >
  976. </div>
  977. </div>
  978. <hr class=" dark:border-gray-700" />
  979. <div>
  980. <div class=" mb-2.5 text-sm font-medium">
  981. OpenAI API Key <span class=" text-gray-400 text-sm">(optional)</span>
  982. </div>
  983. <div class="flex w-full">
  984. <div class="flex-1">
  985. <input
  986. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  987. placeholder="Enter OpenAI API Key"
  988. bind:value={OPENAI_API_KEY}
  989. autocomplete="off"
  990. />
  991. </div>
  992. </div>
  993. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  994. Adds optional support for 'gpt-*' models available.
  995. </div>
  996. </div>
  997. </div>
  998. <div class="flex justify-end pt-3 text-sm font-medium">
  999. <button
  1000. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  1001. type="submit"
  1002. >
  1003. Save
  1004. </button>
  1005. </div>
  1006. </form>
  1007. {:else if selectedTab === 'auth'}
  1008. <form
  1009. class="flex flex-col h-full justify-between space-y-3 text-sm"
  1010. on:submit|preventDefault={() => {
  1011. console.log('auth save');
  1012. saveSettings({
  1013. authHeader: authEnabled ? `${authType} ${authContent}` : undefined
  1014. });
  1015. show = false;
  1016. }}
  1017. >
  1018. <div class=" space-y-3">
  1019. <div>
  1020. <div class=" py-1 flex w-full justify-between">
  1021. <div class=" self-center text-sm font-medium">Authorization Header</div>
  1022. <button
  1023. class="p-1 px-3 text-xs flex rounded transition"
  1024. type="button"
  1025. on:click={() => {
  1026. toggleAuthHeader();
  1027. }}
  1028. >
  1029. {#if authEnabled === true}
  1030. <svg
  1031. xmlns="http://www.w3.org/2000/svg"
  1032. viewBox="0 0 24 24"
  1033. fill="currentColor"
  1034. class="w-4 h-4"
  1035. >
  1036. <path
  1037. fill-rule="evenodd"
  1038. 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"
  1039. clip-rule="evenodd"
  1040. />
  1041. </svg>
  1042. <span class="ml-2 self-center"> On </span>
  1043. {:else}
  1044. <svg
  1045. xmlns="http://www.w3.org/2000/svg"
  1046. viewBox="0 0 24 24"
  1047. fill="currentColor"
  1048. class="w-4 h-4"
  1049. >
  1050. <path
  1051. 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"
  1052. />
  1053. </svg>
  1054. <span class="ml-2 self-center">Off</span>
  1055. {/if}
  1056. </button>
  1057. </div>
  1058. </div>
  1059. {#if authEnabled}
  1060. <hr class=" dark:border-gray-700" />
  1061. <div class="mt-2">
  1062. <div class=" py-1 flex w-full space-x-2">
  1063. <button
  1064. class=" py-1 font-semibold flex rounded transition"
  1065. on:click={() => {
  1066. authType = authType === 'Basic' ? 'Bearer' : 'Basic';
  1067. }}
  1068. type="button"
  1069. >
  1070. {#if authType === 'Basic'}
  1071. <span class="self-center mr-2">Basic</span>
  1072. {:else if authType === 'Bearer'}
  1073. <span class="self-center mr-2">Bearer</span>
  1074. {/if}
  1075. </button>
  1076. <div class="flex-1">
  1077. <input
  1078. class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
  1079. placeholder="Enter Authorization Header Content"
  1080. bind:value={authContent}
  1081. />
  1082. </div>
  1083. </div>
  1084. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1085. Toggle between <span class=" text-gray-500 dark:text-gray-300 font-medium"
  1086. >'Basic'</span
  1087. >
  1088. and <span class=" text-gray-500 dark:text-gray-300 font-medium">'Bearer'</span> by
  1089. clicking on the label next to the input.
  1090. </div>
  1091. </div>
  1092. <hr class=" dark:border-gray-700" />
  1093. <div>
  1094. <div class=" mb-2.5 text-sm font-medium">Preview Authorization Header</div>
  1095. <textarea
  1096. value={JSON.stringify({
  1097. Authorization: `${authType} ${authContent}`
  1098. })}
  1099. class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
  1100. rows="2"
  1101. disabled
  1102. />
  1103. </div>
  1104. {/if}
  1105. </div>
  1106. <div class="flex justify-end pt-3 text-sm font-medium">
  1107. <button
  1108. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  1109. type="submit"
  1110. >
  1111. Save
  1112. </button>
  1113. </div>
  1114. </form>
  1115. {:else if selectedTab === 'about'}
  1116. <div class="flex flex-col h-full justify-between space-y-3 text-sm mb-6">
  1117. <div class=" space-y-3">
  1118. <div>
  1119. <div class=" mb-2.5 text-sm font-medium">Ollama Web UI Version</div>
  1120. <div class="flex w-full">
  1121. <div class="flex-1 text-xs text-gray-700 dark:text-gray-200">
  1122. {$config && $config.version ? $config.version : WEB_UI_VERSION}
  1123. </div>
  1124. </div>
  1125. </div>
  1126. <hr class=" dark:border-gray-700" />
  1127. <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
  1128. Created by <a
  1129. class=" text-gray-500 dark:text-gray-300 font-medium"
  1130. href="https://github.com/tjbck"
  1131. target="_blank">Timothy J. Baek</a
  1132. >
  1133. </div>
  1134. <div>
  1135. <a href="https://github.com/ollama-webui/ollama-webui">
  1136. <img
  1137. alt="Github Repo"
  1138. src="https://img.shields.io/github/stars/ollama-webui/ollama-webui?style=social&label=Star us on Github"
  1139. />
  1140. </a>
  1141. </div>
  1142. </div>
  1143. </div>
  1144. {/if}
  1145. </div>
  1146. </div>
  1147. </div>
  1148. </Modal>
  1149. <style>
  1150. input::-webkit-outer-spin-button,
  1151. input::-webkit-inner-spin-button {
  1152. /* display: none; <- Crashes Chrome on hover */
  1153. -webkit-appearance: none;
  1154. margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
  1155. }
  1156. .tabs::-webkit-scrollbar {
  1157. display: none; /* for Chrome, Safari and Opera */
  1158. }
  1159. .tabs {
  1160. -ms-overflow-style: none; /* IE and Edge */
  1161. scrollbar-width: none; /* Firefox */
  1162. }
  1163. input[type='number'] {
  1164. -moz-appearance: textfield; /* Firefox */
  1165. }
  1166. </style>