AdvancedParams.svelte 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550
  1. <script lang="ts">
  2. import Switch from '$lib/components/common/Switch.svelte';
  3. import Textarea from '$lib/components/common/Textarea.svelte';
  4. import Tooltip from '$lib/components/common/Tooltip.svelte';
  5. import Plus from '$lib/components/icons/Plus.svelte';
  6. import { getContext } from 'svelte';
  7. const i18n = getContext('i18n');
  8. export let onChange: (params: any) => void = () => {};
  9. export let admin = false;
  10. export let custom = false;
  11. const defaultParams = {
  12. // Advanced
  13. stream_response: null, // Set stream responses for this model individually
  14. function_calling: null,
  15. seed: null,
  16. stop: null,
  17. temperature: null,
  18. reasoning_effort: null,
  19. logit_bias: null,
  20. max_tokens: null,
  21. top_k: null,
  22. top_p: null,
  23. min_p: null,
  24. frequency_penalty: null,
  25. presence_penalty: null,
  26. mirostat: null,
  27. mirostat_eta: null,
  28. mirostat_tau: null,
  29. repeat_last_n: null,
  30. tfs_z: null,
  31. repeat_penalty: null,
  32. use_mmap: null,
  33. use_mlock: null,
  34. think: null,
  35. format: null,
  36. keep_alive: null,
  37. num_keep: null,
  38. num_ctx: null,
  39. num_batch: null,
  40. num_thread: null,
  41. num_gpu: null
  42. };
  43. export let params = defaultParams;
  44. $: if (params) {
  45. onChange(params);
  46. }
  47. </script>
  48. <div class=" space-y-1 text-xs pb-safe-bottom">
  49. <div>
  50. <Tooltip
  51. content={$i18n.t(
  52. 'When enabled, the model will respond to each chat message in real-time, generating a response as soon as the user sends a message. This mode is useful for live chat applications, but may impact performance on slower hardware.'
  53. )}
  54. placement="top-start"
  55. className="inline-tooltip"
  56. >
  57. <div class=" py-0.5 flex w-full justify-between">
  58. <div class=" self-center text-xs font-medium">
  59. {$i18n.t('Stream Chat Response')}
  60. </div>
  61. <button
  62. class="p-1 px-3 text-xs flex rounded-sm transition"
  63. on:click={() => {
  64. params.stream_response =
  65. (params?.stream_response ?? null) === null
  66. ? true
  67. : params.stream_response
  68. ? false
  69. : null;
  70. }}
  71. type="button"
  72. >
  73. {#if params.stream_response === true}
  74. <span class="ml-2 self-center">{$i18n.t('On')}</span>
  75. {:else if params.stream_response === false}
  76. <span class="ml-2 self-center">{$i18n.t('Off')}</span>
  77. {:else}
  78. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  79. {/if}
  80. </button>
  81. </div>
  82. </Tooltip>
  83. </div>
  84. <div>
  85. <Tooltip
  86. content={$i18n.t(
  87. "Default mode works with a wider range of models by calling tools once before execution. Native mode leverages the model's built-in tool-calling capabilities, but requires the model to inherently support this feature."
  88. )}
  89. placement="top-start"
  90. className="inline-tooltip"
  91. >
  92. <div class=" py-0.5 flex w-full justify-between">
  93. <div class=" self-center text-xs font-medium">
  94. {$i18n.t('Function Calling')}
  95. </div>
  96. <button
  97. class="p-1 px-3 text-xs flex rounded-sm transition"
  98. on:click={() => {
  99. params.function_calling = (params?.function_calling ?? null) === null ? 'native' : null;
  100. }}
  101. type="button"
  102. >
  103. {#if params.function_calling === 'native'}
  104. <span class="ml-2 self-center">{$i18n.t('Native')}</span>
  105. {:else}
  106. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  107. {/if}
  108. </button>
  109. </div>
  110. </Tooltip>
  111. </div>
  112. <div class=" py-0.5 w-full justify-between">
  113. <Tooltip
  114. content={$i18n.t(
  115. 'Sets the random number seed to use for generation. Setting this to a specific number will make the model generate the same text for the same prompt.'
  116. )}
  117. placement="top-start"
  118. className="inline-tooltip"
  119. >
  120. <div class="flex w-full justify-between">
  121. <div class=" self-center text-xs font-medium">
  122. {$i18n.t('Seed')}
  123. </div>
  124. <button
  125. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  126. type="button"
  127. on:click={() => {
  128. params.seed = (params?.seed ?? null) === null ? 0 : null;
  129. }}
  130. >
  131. {#if (params?.seed ?? null) === null}
  132. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  133. {:else}
  134. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  135. {/if}
  136. </button>
  137. </div>
  138. </Tooltip>
  139. {#if (params?.seed ?? null) !== null}
  140. <div class="flex mt-0.5 space-x-2">
  141. <div class=" flex-1">
  142. <input
  143. class="text-sm w-full bg-transparent outline-hidden outline-none"
  144. type="number"
  145. placeholder={$i18n.t('Enter Seed')}
  146. bind:value={params.seed}
  147. autocomplete="off"
  148. min="0"
  149. />
  150. </div>
  151. </div>
  152. {/if}
  153. </div>
  154. <div class=" py-0.5 w-full justify-between">
  155. <Tooltip
  156. content={$i18n.t(
  157. 'Sets the stop sequences to use. When this pattern is encountered, the LLM will stop generating text and return. Multiple stop patterns may be set by specifying multiple separate stop parameters in a modelfile.'
  158. )}
  159. placement="top-start"
  160. className="inline-tooltip"
  161. >
  162. <div class="flex w-full justify-between">
  163. <div class=" self-center text-xs font-medium">
  164. {$i18n.t('Stop Sequence')}
  165. </div>
  166. <button
  167. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  168. type="button"
  169. on:click={() => {
  170. params.stop = (params?.stop ?? null) === null ? '' : null;
  171. }}
  172. >
  173. {#if (params?.stop ?? null) === null}
  174. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  175. {:else}
  176. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  177. {/if}
  178. </button>
  179. </div>
  180. </Tooltip>
  181. {#if (params?.stop ?? null) !== null}
  182. <div class="flex mt-0.5 space-x-2">
  183. <div class=" flex-1">
  184. <input
  185. class="text-sm w-full bg-transparent outline-hidden outline-none"
  186. type="text"
  187. placeholder={$i18n.t('Enter stop sequence')}
  188. bind:value={params.stop}
  189. autocomplete="off"
  190. />
  191. </div>
  192. </div>
  193. {/if}
  194. </div>
  195. <div class=" py-0.5 w-full justify-between">
  196. <Tooltip
  197. content={$i18n.t(
  198. 'The temperature of the model. Increasing the temperature will make the model answer more creatively.'
  199. )}
  200. placement="top-start"
  201. className="inline-tooltip"
  202. >
  203. <div class="flex w-full justify-between">
  204. <div class=" self-center text-xs font-medium">
  205. {$i18n.t('Temperature')}
  206. </div>
  207. <button
  208. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  209. type="button"
  210. on:click={() => {
  211. params.temperature = (params?.temperature ?? null) === null ? 0.8 : null;
  212. }}
  213. >
  214. {#if (params?.temperature ?? null) === null}
  215. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  216. {:else}
  217. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  218. {/if}
  219. </button>
  220. </div>
  221. </Tooltip>
  222. {#if (params?.temperature ?? null) !== null}
  223. <div class="flex mt-0.5 space-x-2">
  224. <div class=" flex-1">
  225. <input
  226. id="steps-range"
  227. type="range"
  228. min="0"
  229. max="2"
  230. step="0.05"
  231. bind:value={params.temperature}
  232. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  233. />
  234. </div>
  235. <div>
  236. <input
  237. bind:value={params.temperature}
  238. type="number"
  239. class=" bg-transparent text-center w-14"
  240. min="0"
  241. max="2"
  242. step="any"
  243. />
  244. </div>
  245. </div>
  246. {/if}
  247. </div>
  248. <div class=" py-0.5 w-full justify-between">
  249. <Tooltip
  250. content={$i18n.t(
  251. 'Constrains effort on reasoning for reasoning models. Only applicable to reasoning models from specific providers that support reasoning effort.'
  252. )}
  253. placement="top-start"
  254. className="inline-tooltip"
  255. >
  256. <div class="flex w-full justify-between">
  257. <div class=" self-center text-xs font-medium">
  258. {$i18n.t('Reasoning Effort')}
  259. </div>
  260. <button
  261. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  262. type="button"
  263. on:click={() => {
  264. params.reasoning_effort = (params?.reasoning_effort ?? null) === null ? 'medium' : null;
  265. }}
  266. >
  267. {#if (params?.reasoning_effort ?? null) === null}
  268. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  269. {:else}
  270. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  271. {/if}
  272. </button>
  273. </div>
  274. </Tooltip>
  275. {#if (params?.reasoning_effort ?? null) !== null}
  276. <div class="flex mt-0.5 space-x-2">
  277. <div class=" flex-1">
  278. <input
  279. class="text-sm w-full bg-transparent outline-hidden outline-none"
  280. type="text"
  281. placeholder={$i18n.t('Enter reasoning effort')}
  282. bind:value={params.reasoning_effort}
  283. autocomplete="off"
  284. />
  285. </div>
  286. </div>
  287. {/if}
  288. </div>
  289. <div class=" py-0.5 w-full justify-between">
  290. <Tooltip
  291. content={$i18n.t(
  292. 'Boosting or penalizing specific tokens for constrained responses. Bias values will be clamped between -100 and 100 (inclusive). (Default: none)'
  293. )}
  294. placement="top-start"
  295. className="inline-tooltip"
  296. >
  297. <div class="flex w-full justify-between">
  298. <div class=" self-center text-xs font-medium">
  299. {'logit_bias'}
  300. </div>
  301. <button
  302. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  303. type="button"
  304. on:click={() => {
  305. params.logit_bias = (params?.logit_bias ?? null) === null ? '' : null;
  306. }}
  307. >
  308. {#if (params?.logit_bias ?? null) === null}
  309. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  310. {:else}
  311. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  312. {/if}
  313. </button>
  314. </div>
  315. </Tooltip>
  316. {#if (params?.logit_bias ?? null) !== null}
  317. <div class="flex mt-0.5 space-x-2">
  318. <div class=" flex-1">
  319. <input
  320. class="text-sm w-full bg-transparent outline-hidden outline-none"
  321. type="text"
  322. placeholder={$i18n.t(
  323. 'Enter comma-separated "token:bias_value" pairs (example: 5432:100, 413:-100)'
  324. )}
  325. bind:value={params.logit_bias}
  326. autocomplete="off"
  327. />
  328. </div>
  329. </div>
  330. {/if}
  331. </div>
  332. <div class=" py-0.5 w-full justify-between">
  333. <Tooltip
  334. content={$i18n.t(
  335. 'This option sets the maximum number of tokens the model can generate in its response. Increasing this limit allows the model to provide longer answers, but it may also increase the likelihood of unhelpful or irrelevant content being generated.'
  336. )}
  337. placement="top-start"
  338. className="inline-tooltip"
  339. >
  340. <div class="flex w-full justify-between">
  341. <div class=" self-center text-xs font-medium">
  342. {'max_tokens'}
  343. </div>
  344. <button
  345. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  346. type="button"
  347. on:click={() => {
  348. params.max_tokens = (params?.max_tokens ?? null) === null ? 128 : null;
  349. }}
  350. >
  351. {#if (params?.max_tokens ?? null) === null}
  352. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  353. {:else}
  354. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  355. {/if}
  356. </button>
  357. </div>
  358. </Tooltip>
  359. {#if (params?.max_tokens ?? null) !== null}
  360. <div class="flex mt-0.5 space-x-2">
  361. <div class=" flex-1">
  362. <input
  363. id="steps-range"
  364. type="range"
  365. min="-2"
  366. max="131072"
  367. step="1"
  368. bind:value={params.max_tokens}
  369. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  370. />
  371. </div>
  372. <div>
  373. <input
  374. bind:value={params.max_tokens}
  375. type="number"
  376. class=" bg-transparent text-center w-14"
  377. min="-2"
  378. step="1"
  379. />
  380. </div>
  381. </div>
  382. {/if}
  383. </div>
  384. <div class=" py-0.5 w-full justify-between">
  385. <Tooltip
  386. content={$i18n.t(
  387. 'Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a lower value (e.g. 10) will be more conservative.'
  388. )}
  389. placement="top-start"
  390. className="inline-tooltip"
  391. >
  392. <div class="flex w-full justify-between">
  393. <div class=" self-center text-xs font-medium">
  394. {'top_k'}
  395. </div>
  396. <button
  397. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  398. type="button"
  399. on:click={() => {
  400. params.top_k = (params?.top_k ?? null) === null ? 40 : null;
  401. }}
  402. >
  403. {#if (params?.top_k ?? null) === null}
  404. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  405. {:else}
  406. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  407. {/if}
  408. </button>
  409. </div>
  410. </Tooltip>
  411. {#if (params?.top_k ?? null) !== null}
  412. <div class="flex mt-0.5 space-x-2">
  413. <div class=" flex-1">
  414. <input
  415. id="steps-range"
  416. type="range"
  417. min="0"
  418. max="1000"
  419. step="0.5"
  420. bind:value={params.top_k}
  421. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  422. />
  423. </div>
  424. <div>
  425. <input
  426. bind:value={params.top_k}
  427. type="number"
  428. class=" bg-transparent text-center w-14"
  429. min="0"
  430. max="100"
  431. step="any"
  432. />
  433. </div>
  434. </div>
  435. {/if}
  436. </div>
  437. <div class=" py-0.5 w-full justify-between">
  438. <Tooltip
  439. content={$i18n.t(
  440. 'Works together with top-k. A higher value (e.g., 0.95) will lead to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text.'
  441. )}
  442. placement="top-start"
  443. className="inline-tooltip"
  444. >
  445. <div class="flex w-full justify-between">
  446. <div class=" self-center text-xs font-medium">
  447. {'top_p'}
  448. </div>
  449. <button
  450. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  451. type="button"
  452. on:click={() => {
  453. params.top_p = (params?.top_p ?? null) === null ? 0.9 : null;
  454. }}
  455. >
  456. {#if (params?.top_p ?? null) === null}
  457. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  458. {:else}
  459. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  460. {/if}
  461. </button>
  462. </div>
  463. </Tooltip>
  464. {#if (params?.top_p ?? null) !== null}
  465. <div class="flex mt-0.5 space-x-2">
  466. <div class=" flex-1">
  467. <input
  468. id="steps-range"
  469. type="range"
  470. min="0"
  471. max="1"
  472. step="0.05"
  473. bind:value={params.top_p}
  474. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  475. />
  476. </div>
  477. <div>
  478. <input
  479. bind:value={params.top_p}
  480. type="number"
  481. class=" bg-transparent text-center w-14"
  482. min="0"
  483. max="1"
  484. step="any"
  485. />
  486. </div>
  487. </div>
  488. {/if}
  489. </div>
  490. <div class=" py-0.5 w-full justify-between">
  491. <Tooltip
  492. content={$i18n.t(
  493. 'Alternative to the top_p, and aims to ensure a balance of quality and variety. The parameter p represents the minimum probability for a token to be considered, relative to the probability of the most likely token. For example, with p=0.05 and the most likely token having a probability of 0.9, logits with a value less than 0.045 are filtered out.'
  494. )}
  495. placement="top-start"
  496. className="inline-tooltip"
  497. >
  498. <div class="flex w-full justify-between">
  499. <div class=" self-center text-xs font-medium">
  500. {'min_p'}
  501. </div>
  502. <button
  503. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  504. type="button"
  505. on:click={() => {
  506. params.min_p = (params?.min_p ?? null) === null ? 0.0 : null;
  507. }}
  508. >
  509. {#if (params?.min_p ?? null) === null}
  510. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  511. {:else}
  512. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  513. {/if}
  514. </button>
  515. </div>
  516. </Tooltip>
  517. {#if (params?.min_p ?? null) !== null}
  518. <div class="flex mt-0.5 space-x-2">
  519. <div class=" flex-1">
  520. <input
  521. id="steps-range"
  522. type="range"
  523. min="0"
  524. max="1"
  525. step="0.05"
  526. bind:value={params.min_p}
  527. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  528. />
  529. </div>
  530. <div>
  531. <input
  532. bind:value={params.min_p}
  533. type="number"
  534. class=" bg-transparent text-center w-14"
  535. min="0"
  536. max="1"
  537. step="any"
  538. />
  539. </div>
  540. </div>
  541. {/if}
  542. </div>
  543. <div class=" py-0.5 w-full justify-between">
  544. <Tooltip
  545. content={$i18n.t(
  546. 'Sets a scaling bias against tokens to penalize repetitions, based on how many times they have appeared. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. At 0, it is disabled.'
  547. )}
  548. placement="top-start"
  549. className="inline-tooltip"
  550. >
  551. <div class="flex w-full justify-between">
  552. <div class=" self-center text-xs font-medium">
  553. {'frequency_penalty'}
  554. </div>
  555. <button
  556. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  557. type="button"
  558. on:click={() => {
  559. params.frequency_penalty = (params?.frequency_penalty ?? null) === null ? 1.1 : null;
  560. }}
  561. >
  562. {#if (params?.frequency_penalty ?? null) === null}
  563. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  564. {:else}
  565. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  566. {/if}
  567. </button>
  568. </div>
  569. </Tooltip>
  570. {#if (params?.frequency_penalty ?? null) !== null}
  571. <div class="flex mt-0.5 space-x-2">
  572. <div class=" flex-1">
  573. <input
  574. id="steps-range"
  575. type="range"
  576. min="-2"
  577. max="2"
  578. step="0.05"
  579. bind:value={params.frequency_penalty}
  580. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  581. />
  582. </div>
  583. <div>
  584. <input
  585. bind:value={params.frequency_penalty}
  586. type="number"
  587. class=" bg-transparent text-center w-14"
  588. min="-2"
  589. max="2"
  590. step="any"
  591. />
  592. </div>
  593. </div>
  594. {/if}
  595. </div>
  596. <div class=" py-0.5 w-full justify-between">
  597. <Tooltip
  598. content={$i18n.t(
  599. 'Sets a flat bias against tokens that have appeared at least once. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. At 0, it is disabled.'
  600. )}
  601. placement="top-start"
  602. className="inline-tooltip"
  603. >
  604. <div class="flex w-full justify-between">
  605. <div class=" self-center text-xs font-medium">
  606. {'presence_penalty'}
  607. </div>
  608. <button
  609. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  610. type="button"
  611. on:click={() => {
  612. params.presence_penalty = (params?.presence_penalty ?? null) === null ? 0.0 : null;
  613. }}
  614. >
  615. {#if (params?.presence_penalty ?? null) === null}
  616. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  617. {:else}
  618. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  619. {/if}
  620. </button>
  621. </div>
  622. </Tooltip>
  623. {#if (params?.presence_penalty ?? null) !== null}
  624. <div class="flex mt-0.5 space-x-2">
  625. <div class=" flex-1">
  626. <input
  627. id="steps-range"
  628. type="range"
  629. min="-2"
  630. max="2"
  631. step="0.05"
  632. bind:value={params.presence_penalty}
  633. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  634. />
  635. </div>
  636. <div>
  637. <input
  638. bind:value={params.presence_penalty}
  639. type="number"
  640. class=" bg-transparent text-center w-14"
  641. min="-2"
  642. max="2"
  643. step="any"
  644. />
  645. </div>
  646. </div>
  647. {/if}
  648. </div>
  649. <div class=" py-0.5 w-full justify-between">
  650. <Tooltip
  651. content={$i18n.t('Enable Mirostat sampling for controlling perplexity.')}
  652. placement="top-start"
  653. className="inline-tooltip"
  654. >
  655. <div class="flex w-full justify-between">
  656. <div class=" self-center text-xs font-medium">
  657. {'mirostat'}
  658. </div>
  659. <button
  660. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  661. type="button"
  662. on:click={() => {
  663. params.mirostat = (params?.mirostat ?? null) === null ? 0 : null;
  664. }}
  665. >
  666. {#if (params?.mirostat ?? null) === null}
  667. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  668. {:else}
  669. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  670. {/if}
  671. </button>
  672. </div>
  673. </Tooltip>
  674. {#if (params?.mirostat ?? null) !== null}
  675. <div class="flex mt-0.5 space-x-2">
  676. <div class=" flex-1">
  677. <input
  678. id="steps-range"
  679. type="range"
  680. min="0"
  681. max="2"
  682. step="1"
  683. bind:value={params.mirostat}
  684. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  685. />
  686. </div>
  687. <div>
  688. <input
  689. bind:value={params.mirostat}
  690. type="number"
  691. class=" bg-transparent text-center w-14"
  692. min="0"
  693. max="2"
  694. step="1"
  695. />
  696. </div>
  697. </div>
  698. {/if}
  699. </div>
  700. <div class=" py-0.5 w-full justify-between">
  701. <Tooltip
  702. content={$i18n.t(
  703. 'Influences how quickly the algorithm responds to feedback from the generated text. A lower learning rate will result in slower adjustments, while a higher learning rate will make the algorithm more responsive.'
  704. )}
  705. placement="top-start"
  706. className="inline-tooltip"
  707. >
  708. <div class="flex w-full justify-between">
  709. <div class=" self-center text-xs font-medium">
  710. {'mirostat_eta'}
  711. </div>
  712. <button
  713. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  714. type="button"
  715. on:click={() => {
  716. params.mirostat_eta = (params?.mirostat_eta ?? null) === null ? 0.1 : null;
  717. }}
  718. >
  719. {#if (params?.mirostat_eta ?? null) === null}
  720. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  721. {:else}
  722. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  723. {/if}
  724. </button>
  725. </div>
  726. </Tooltip>
  727. {#if (params?.mirostat_eta ?? null) !== null}
  728. <div class="flex mt-0.5 space-x-2">
  729. <div class=" flex-1">
  730. <input
  731. id="steps-range"
  732. type="range"
  733. min="0"
  734. max="1"
  735. step="0.05"
  736. bind:value={params.mirostat_eta}
  737. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  738. />
  739. </div>
  740. <div>
  741. <input
  742. bind:value={params.mirostat_eta}
  743. type="number"
  744. class=" bg-transparent text-center w-14"
  745. min="0"
  746. max="1"
  747. step="any"
  748. />
  749. </div>
  750. </div>
  751. {/if}
  752. </div>
  753. <div class=" py-0.5 w-full justify-between">
  754. <Tooltip
  755. content={$i18n.t(
  756. 'Controls the balance between coherence and diversity of the output. A lower value will result in more focused and coherent text.'
  757. )}
  758. placement="top-start"
  759. className="inline-tooltip"
  760. >
  761. <div class="flex w-full justify-between">
  762. <div class=" self-center text-xs font-medium">
  763. {'mirostat_tau'}
  764. </div>
  765. <button
  766. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  767. type="button"
  768. on:click={() => {
  769. params.mirostat_tau = (params?.mirostat_tau ?? null) === null ? 5.0 : null;
  770. }}
  771. >
  772. {#if (params?.mirostat_tau ?? null) === null}
  773. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  774. {:else}
  775. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  776. {/if}
  777. </button>
  778. </div>
  779. </Tooltip>
  780. {#if (params?.mirostat_tau ?? null) !== null}
  781. <div class="flex mt-0.5 space-x-2">
  782. <div class=" flex-1">
  783. <input
  784. id="steps-range"
  785. type="range"
  786. min="0"
  787. max="10"
  788. step="0.5"
  789. bind:value={params.mirostat_tau}
  790. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  791. />
  792. </div>
  793. <div>
  794. <input
  795. bind:value={params.mirostat_tau}
  796. type="number"
  797. class=" bg-transparent text-center w-14"
  798. min="0"
  799. max="10"
  800. step="any"
  801. />
  802. </div>
  803. </div>
  804. {/if}
  805. </div>
  806. <div class=" py-0.5 w-full justify-between">
  807. <Tooltip
  808. content={$i18n.t('Sets how far back for the model to look back to prevent repetition.')}
  809. placement="top-start"
  810. className="inline-tooltip"
  811. >
  812. <div class="flex w-full justify-between">
  813. <div class=" self-center text-xs font-medium">
  814. {'repeat_last_n'}
  815. </div>
  816. <button
  817. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  818. type="button"
  819. on:click={() => {
  820. params.repeat_last_n = (params?.repeat_last_n ?? null) === null ? 64 : null;
  821. }}
  822. >
  823. {#if (params?.repeat_last_n ?? null) === null}
  824. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  825. {:else}
  826. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  827. {/if}
  828. </button>
  829. </div>
  830. </Tooltip>
  831. {#if (params?.repeat_last_n ?? null) !== null}
  832. <div class="flex mt-0.5 space-x-2">
  833. <div class=" flex-1">
  834. <input
  835. id="steps-range"
  836. type="range"
  837. min="-1"
  838. max="128"
  839. step="1"
  840. bind:value={params.repeat_last_n}
  841. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  842. />
  843. </div>
  844. <div>
  845. <input
  846. bind:value={params.repeat_last_n}
  847. type="number"
  848. class=" bg-transparent text-center w-14"
  849. min="-1"
  850. max="128"
  851. step="1"
  852. />
  853. </div>
  854. </div>
  855. {/if}
  856. </div>
  857. <div class=" py-0.5 w-full justify-between">
  858. <Tooltip
  859. content={$i18n.t(
  860. 'Tail free sampling is used to reduce the impact of less probable tokens from the output. A higher value (e.g., 2.0) will reduce the impact more, while a value of 1.0 disables this setting.'
  861. )}
  862. placement="top-start"
  863. className="inline-tooltip"
  864. >
  865. <div class="flex w-full justify-between">
  866. <div class=" self-center text-xs font-medium">
  867. {'tfs_z'}
  868. </div>
  869. <button
  870. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  871. type="button"
  872. on:click={() => {
  873. params.tfs_z = (params?.tfs_z ?? null) === null ? 1 : null;
  874. }}
  875. >
  876. {#if (params?.tfs_z ?? null) === null}
  877. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  878. {:else}
  879. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  880. {/if}
  881. </button>
  882. </div>
  883. </Tooltip>
  884. {#if (params?.tfs_z ?? null) !== null}
  885. <div class="flex mt-0.5 space-x-2">
  886. <div class=" flex-1">
  887. <input
  888. id="steps-range"
  889. type="range"
  890. min="0"
  891. max="2"
  892. step="0.05"
  893. bind:value={params.tfs_z}
  894. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  895. />
  896. </div>
  897. <div>
  898. <input
  899. bind:value={params.tfs_z}
  900. type="number"
  901. class=" bg-transparent text-center w-14"
  902. min="0"
  903. max="2"
  904. step="any"
  905. />
  906. </div>
  907. </div>
  908. {/if}
  909. </div>
  910. <div class=" py-0.5 w-full justify-between">
  911. <Tooltip
  912. content={$i18n.t(
  913. 'Control the repetition of token sequences in the generated text. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 1.1) will be more lenient. At 1, it is disabled.'
  914. )}
  915. placement="top-start"
  916. className="inline-tooltip"
  917. >
  918. <div class="flex w-full justify-between">
  919. <div class=" self-center text-xs font-medium">
  920. {'repeat_penalty'}
  921. </div>
  922. <button
  923. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  924. type="button"
  925. on:click={() => {
  926. params.repeat_penalty = (params?.repeat_penalty ?? null) === null ? 1.1 : null;
  927. }}
  928. >
  929. {#if (params?.repeat_penalty ?? null) === null}
  930. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  931. {:else}
  932. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  933. {/if}
  934. </button>
  935. </div>
  936. </Tooltip>
  937. {#if (params?.repeat_penalty ?? null) !== null}
  938. <div class="flex mt-0.5 space-x-2">
  939. <div class=" flex-1">
  940. <input
  941. id="steps-range"
  942. type="range"
  943. min="-2"
  944. max="2"
  945. step="0.05"
  946. bind:value={params.repeat_penalty}
  947. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  948. />
  949. </div>
  950. <div>
  951. <input
  952. bind:value={params.repeat_penalty}
  953. type="number"
  954. class=" bg-transparent text-center w-14"
  955. min="-2"
  956. max="2"
  957. step="any"
  958. />
  959. </div>
  960. </div>
  961. {/if}
  962. </div>
  963. {#if admin}
  964. <div class=" py-0.5 w-full justify-between">
  965. <Tooltip
  966. content={$i18n.t(
  967. 'Enable Memory Mapping (mmap) to load model data. This option allows the system to use disk storage as an extension of RAM by treating disk files as if they were in RAM. This can improve model performance by allowing for faster data access. However, it may not work correctly with all systems and can consume a significant amount of disk space.'
  968. )}
  969. placement="top-start"
  970. className="inline-tooltip"
  971. >
  972. <div class="flex w-full justify-between">
  973. <div class=" self-center text-xs font-medium">
  974. {'use_mmap'}
  975. </div>
  976. <button
  977. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  978. type="button"
  979. on:click={() => {
  980. params.use_mmap = (params?.use_mmap ?? null) === null ? true : null;
  981. }}
  982. >
  983. {#if (params?.use_mmap ?? null) === null}
  984. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  985. {:else}
  986. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  987. {/if}
  988. </button>
  989. </div>
  990. </Tooltip>
  991. {#if (params?.use_mmap ?? null) !== null}
  992. <div class="flex justify-between items-center mt-1">
  993. <div class="text-xs text-gray-500">
  994. {params.use_mmap ? 'Enabled' : 'Disabled'}
  995. </div>
  996. <div class=" pr-2">
  997. <Switch bind:state={params.use_mmap} />
  998. </div>
  999. </div>
  1000. {/if}
  1001. </div>
  1002. <div class=" py-0.5 w-full justify-between">
  1003. <Tooltip
  1004. content={$i18n.t(
  1005. "Enable Memory Locking (mlock) to prevent model data from being swapped out of RAM. This option locks the model's working set of pages into RAM, ensuring that they will not be swapped out to disk. This can help maintain performance by avoiding page faults and ensuring fast data access."
  1006. )}
  1007. placement="top-start"
  1008. className="inline-tooltip"
  1009. >
  1010. <div class="flex w-full justify-between">
  1011. <div class=" self-center text-xs font-medium">
  1012. {'use_mlock'}
  1013. </div>
  1014. <button
  1015. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1016. type="button"
  1017. on:click={() => {
  1018. params.use_mlock = (params?.use_mlock ?? null) === null ? true : null;
  1019. }}
  1020. >
  1021. {#if (params?.use_mlock ?? null) === null}
  1022. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1023. {:else}
  1024. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1025. {/if}
  1026. </button>
  1027. </div>
  1028. </Tooltip>
  1029. {#if (params?.use_mlock ?? null) !== null}
  1030. <div class="flex justify-between items-center mt-1">
  1031. <div class="text-xs text-gray-500">
  1032. {params.use_mlock ? 'Enabled' : 'Disabled'}
  1033. </div>
  1034. <div class=" pr-2">
  1035. <Switch bind:state={params.use_mlock} />
  1036. </div>
  1037. </div>
  1038. {/if}
  1039. </div>
  1040. {/if}
  1041. <div class=" py-0.5 w-full justify-between">
  1042. <Tooltip
  1043. content={$i18n.t(
  1044. 'This option enables or disables the use of the reasoning feature in Ollama, which allows the model to think before generating a response. When enabled, the model can take a moment to process the conversation context and generate a more thoughtful response.'
  1045. )}
  1046. placement="top-start"
  1047. className="inline-tooltip"
  1048. >
  1049. <div class=" py-0.5 flex w-full justify-between">
  1050. <div class=" self-center text-xs font-medium">
  1051. {'think'} ({$i18n.t('Ollama')})
  1052. </div>
  1053. <button
  1054. class="p-1 px-3 text-xs flex rounded-sm transition"
  1055. on:click={() => {
  1056. params.think = (params?.think ?? null) === null ? true : params.think ? false : null;
  1057. }}
  1058. type="button"
  1059. >
  1060. {#if params.think === true}
  1061. <span class="ml-2 self-center">{$i18n.t('On')}</span>
  1062. {:else if params.think === false}
  1063. <span class="ml-2 self-center">{$i18n.t('Off')}</span>
  1064. {:else}
  1065. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1066. {/if}
  1067. </button>
  1068. </div>
  1069. </Tooltip>
  1070. </div>
  1071. <div class=" py-0.5 w-full justify-between">
  1072. <Tooltip
  1073. content={$i18n.t('The format to return a response in. Format can be json or a JSON schema.')}
  1074. placement="top-start"
  1075. className="inline-tooltip"
  1076. >
  1077. <div class=" py-0.5 flex w-full justify-between">
  1078. <div class=" self-center text-xs font-medium">
  1079. {'format'} ({$i18n.t('Ollama')})
  1080. </div>
  1081. <button
  1082. class="p-1 px-3 text-xs flex rounded-sm transition"
  1083. on:click={() => {
  1084. params.format = (params?.format ?? null) === null ? 'json' : null;
  1085. }}
  1086. type="button"
  1087. >
  1088. {#if (params?.format ?? null) === null}
  1089. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1090. {:else}
  1091. <span class="ml-2 self-center">{$i18n.t('JSON')}</span>
  1092. {/if}
  1093. </button>
  1094. </div>
  1095. </Tooltip>
  1096. {#if (params?.format ?? null) !== null}
  1097. <div class="flex mt-0.5 space-x-2">
  1098. <Textarea
  1099. className="w-full text-sm bg-transparent outline-hidden"
  1100. placeholder={$i18n.t('e.g. "json" or a JSON schema')}
  1101. bind:value={params.format}
  1102. />
  1103. </div>
  1104. {/if}
  1105. </div>
  1106. <div class=" py-0.5 w-full justify-between">
  1107. <Tooltip
  1108. content={$i18n.t(
  1109. 'This option controls how many tokens are preserved when refreshing the context. For example, if set to 2, the last 2 tokens of the conversation context will be retained. Preserving context can help maintain the continuity of a conversation, but it may reduce the ability to respond to new topics.'
  1110. )}
  1111. placement="top-start"
  1112. className="inline-tooltip"
  1113. >
  1114. <div class="flex w-full justify-between">
  1115. <div class=" self-center text-xs font-medium">
  1116. {'num_keep'} ({$i18n.t('Ollama')})
  1117. </div>
  1118. <button
  1119. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1120. type="button"
  1121. on:click={() => {
  1122. params.num_keep = (params?.num_keep ?? null) === null ? 24 : null;
  1123. }}
  1124. >
  1125. {#if (params?.num_keep ?? null) === null}
  1126. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1127. {:else}
  1128. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1129. {/if}
  1130. </button>
  1131. </div>
  1132. </Tooltip>
  1133. {#if (params?.num_keep ?? null) !== null}
  1134. <div class="flex mt-0.5 space-x-2">
  1135. <div class=" flex-1">
  1136. <input
  1137. id="steps-range"
  1138. type="range"
  1139. min="-1"
  1140. max="10240000"
  1141. step="1"
  1142. bind:value={params.num_keep}
  1143. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1144. />
  1145. </div>
  1146. <div class="">
  1147. <input
  1148. bind:value={params.num_keep}
  1149. type="number"
  1150. class=" bg-transparent text-center w-14"
  1151. min="-1"
  1152. step="1"
  1153. />
  1154. </div>
  1155. </div>
  1156. {/if}
  1157. </div>
  1158. <div class=" py-0.5 w-full justify-between">
  1159. <Tooltip
  1160. content={$i18n.t('Sets the size of the context window used to generate the next token.')}
  1161. placement="top-start"
  1162. className="inline-tooltip"
  1163. >
  1164. <div class="flex w-full justify-between">
  1165. <div class=" self-center text-xs font-medium">
  1166. {'num_ctx'} ({$i18n.t('Ollama')})
  1167. </div>
  1168. <button
  1169. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1170. type="button"
  1171. on:click={() => {
  1172. params.num_ctx = (params?.num_ctx ?? null) === null ? 2048 : null;
  1173. }}
  1174. >
  1175. {#if (params?.num_ctx ?? null) === null}
  1176. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1177. {:else}
  1178. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1179. {/if}
  1180. </button>
  1181. </div>
  1182. </Tooltip>
  1183. {#if (params?.num_ctx ?? null) !== null}
  1184. <div class="flex mt-0.5 space-x-2">
  1185. <div class=" flex-1">
  1186. <input
  1187. id="steps-range"
  1188. type="range"
  1189. min="-1"
  1190. max="10240000"
  1191. step="1"
  1192. bind:value={params.num_ctx}
  1193. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1194. />
  1195. </div>
  1196. <div class="">
  1197. <input
  1198. bind:value={params.num_ctx}
  1199. type="number"
  1200. class=" bg-transparent text-center w-14"
  1201. min="-1"
  1202. step="1"
  1203. />
  1204. </div>
  1205. </div>
  1206. {/if}
  1207. </div>
  1208. <div class=" py-0.5 w-full justify-between">
  1209. <Tooltip
  1210. content={$i18n.t(
  1211. 'The batch size determines how many text requests are processed together at once. A higher batch size can increase the performance and speed of the model, but it also requires more memory.'
  1212. )}
  1213. placement="top-start"
  1214. className="inline-tooltip"
  1215. >
  1216. <div class="flex w-full justify-between">
  1217. <div class=" self-center text-xs font-medium">
  1218. {'num_batch'} ({$i18n.t('Ollama')})
  1219. </div>
  1220. <button
  1221. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1222. type="button"
  1223. on:click={() => {
  1224. params.num_batch = (params?.num_batch ?? null) === null ? 512 : null;
  1225. }}
  1226. >
  1227. {#if (params?.num_batch ?? null) === null}
  1228. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1229. {:else}
  1230. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1231. {/if}
  1232. </button>
  1233. </div>
  1234. </Tooltip>
  1235. {#if (params?.num_batch ?? null) !== null}
  1236. <div class="flex mt-0.5 space-x-2">
  1237. <div class=" flex-1">
  1238. <input
  1239. id="steps-range"
  1240. type="range"
  1241. min="256"
  1242. max="8192"
  1243. step="256"
  1244. bind:value={params.num_batch}
  1245. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1246. />
  1247. </div>
  1248. <div>
  1249. <input
  1250. bind:value={params.num_batch}
  1251. type="number"
  1252. class=" bg-transparent text-center w-14"
  1253. min="256"
  1254. step="256"
  1255. />
  1256. </div>
  1257. </div>
  1258. {/if}
  1259. </div>
  1260. {#if admin}
  1261. <div class=" py-0.5 w-full justify-between">
  1262. <Tooltip
  1263. content={$i18n.t(
  1264. 'Set the number of worker threads used for computation. This option controls how many threads are used to process incoming requests concurrently. Increasing this value can improve performance under high concurrency workloads but may also consume more CPU resources.'
  1265. )}
  1266. placement="top-start"
  1267. className="inline-tooltip"
  1268. >
  1269. <div class="flex w-full justify-between">
  1270. <div class=" self-center text-xs font-medium">
  1271. {'num_thread'} ({$i18n.t('Ollama')})
  1272. </div>
  1273. <button
  1274. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1275. type="button"
  1276. on:click={() => {
  1277. params.num_thread = (params?.num_thread ?? null) === null ? 2 : null;
  1278. }}
  1279. >
  1280. {#if (params?.num_thread ?? null) === null}
  1281. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1282. {:else}
  1283. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1284. {/if}
  1285. </button>
  1286. </div>
  1287. </Tooltip>
  1288. {#if (params?.num_thread ?? null) !== null}
  1289. <div class="flex mt-0.5 space-x-2">
  1290. <div class=" flex-1">
  1291. <input
  1292. id="steps-range"
  1293. type="range"
  1294. min="1"
  1295. max="256"
  1296. step="1"
  1297. bind:value={params.num_thread}
  1298. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1299. />
  1300. </div>
  1301. <div class="">
  1302. <input
  1303. bind:value={params.num_thread}
  1304. type="number"
  1305. class=" bg-transparent text-center w-14"
  1306. min="1"
  1307. max="256"
  1308. step="1"
  1309. />
  1310. </div>
  1311. </div>
  1312. {/if}
  1313. </div>
  1314. <div class=" py-0.5 w-full justify-between">
  1315. <Tooltip
  1316. content={$i18n.t(
  1317. 'Set the number of layers, which will be off-loaded to GPU. Increasing this value can significantly improve performance for models that are optimized for GPU acceleration but may also consume more power and GPU resources.'
  1318. )}
  1319. placement="top-start"
  1320. className="inline-tooltip"
  1321. >
  1322. <div class="flex w-full justify-between">
  1323. <div class=" self-center text-xs font-medium">
  1324. {'num_gpu'} ({$i18n.t('Ollama')})
  1325. </div>
  1326. <button
  1327. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1328. type="button"
  1329. on:click={() => {
  1330. params.num_gpu = (params?.num_gpu ?? null) === null ? 0 : null;
  1331. }}
  1332. >
  1333. {#if (params?.num_gpu ?? null) === null}
  1334. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1335. {:else}
  1336. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1337. {/if}
  1338. </button>
  1339. </div>
  1340. </Tooltip>
  1341. {#if (params?.num_gpu ?? null) !== null}
  1342. <div class="flex mt-0.5 space-x-2">
  1343. <div class=" flex-1">
  1344. <input
  1345. id="steps-range"
  1346. type="range"
  1347. min="0"
  1348. max="256"
  1349. step="1"
  1350. bind:value={params.num_gpu}
  1351. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1352. />
  1353. </div>
  1354. <div class="">
  1355. <input
  1356. bind:value={params.num_gpu}
  1357. type="number"
  1358. class=" bg-transparent text-center w-14"
  1359. min="0"
  1360. max="256"
  1361. step="1"
  1362. />
  1363. </div>
  1364. </div>
  1365. {/if}
  1366. </div>
  1367. <div class=" py-0.5 w-full justify-between">
  1368. <Tooltip
  1369. content={$i18n.t(
  1370. 'This option controls how long the model will stay loaded into memory following the request (default: 5m)'
  1371. )}
  1372. placement="top-start"
  1373. className="inline-tooltip"
  1374. >
  1375. <div class=" py-0.5 flex w-full justify-between">
  1376. <div class=" self-center text-xs font-medium">
  1377. {'keep_alive'} ({$i18n.t('Ollama')})
  1378. </div>
  1379. <button
  1380. class="p-1 px-3 text-xs flex rounded-sm transition"
  1381. on:click={() => {
  1382. params.keep_alive = (params?.keep_alive ?? null) === null ? '5m' : null;
  1383. }}
  1384. type="button"
  1385. >
  1386. {#if (params?.keep_alive ?? null) === null}
  1387. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1388. {:else}
  1389. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1390. {/if}
  1391. </button>
  1392. </div>
  1393. </Tooltip>
  1394. {#if (params?.keep_alive ?? null) !== null}
  1395. <div class="flex mt-0.5 space-x-2">
  1396. <input
  1397. class="w-full text-sm bg-transparent outline-hidden"
  1398. type="text"
  1399. placeholder={$i18n.t("e.g. '30s','10m'. Valid time units are 's', 'm', 'h'.")}
  1400. bind:value={params.keep_alive}
  1401. />
  1402. </div>
  1403. {/if}
  1404. </div>
  1405. {#if custom && admin}
  1406. <div class="flex flex-col justify-center">
  1407. {#each Object.keys(params?.custom_params ?? {}) as key}
  1408. <div class=" py-0.5 w-full justify-between mb-1">
  1409. <div class="flex w-full justify-between">
  1410. <div class=" self-center text-xs font-medium">
  1411. <input
  1412. type="text"
  1413. class=" text-xs w-full bg-transparent outline-none"
  1414. placeholder={$i18n.t('Custom Parameter Name')}
  1415. value={key}
  1416. on:change={(e) => {
  1417. const newKey = e.target.value.trim();
  1418. if (newKey && newKey !== key) {
  1419. params.custom_params[newKey] = params.custom_params[key];
  1420. delete params.custom_params[key];
  1421. params = {
  1422. ...params,
  1423. custom_params: { ...params.custom_params }
  1424. };
  1425. }
  1426. }}
  1427. />
  1428. </div>
  1429. <button
  1430. class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
  1431. type="button"
  1432. on:click={() => {
  1433. delete params.custom_params[key];
  1434. params = {
  1435. ...params,
  1436. custom_params: { ...params.custom_params }
  1437. };
  1438. }}
  1439. >
  1440. {$i18n.t('Remove')}
  1441. </button>
  1442. </div>
  1443. <div class="flex mt-0.5 space-x-2">
  1444. <div class=" flex-1">
  1445. <input
  1446. bind:value={params.custom_params[key]}
  1447. type="text"
  1448. class="text-sm w-full bg-transparent outline-hidden outline-none"
  1449. placeholder={$i18n.t('Custom Parameter Value')}
  1450. />
  1451. </div>
  1452. </div>
  1453. </div>
  1454. {/each}
  1455. <button
  1456. class=" flex gap-2 items-center w-full text-center justify-center mt-1 mb-5"
  1457. type="button"
  1458. on:click={() => {
  1459. params.custom_params = (params?.custom_params ?? {}) || {};
  1460. params.custom_params['custom_param_name'] = 'custom_param_value';
  1461. }}
  1462. >
  1463. <div>
  1464. <Plus />
  1465. </div>
  1466. <div>{$i18n.t('Add Custom Parameter')}</div>
  1467. </button>
  1468. </div>
  1469. {/if}
  1470. {/if}
  1471. </div>