AdvancedParams.svelte 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. <script lang="ts">
  2. import Switch from '$lib/components/common/Switch.svelte';
  3. import { getContext, createEventDispatcher } from 'svelte';
  4. const dispatch = createEventDispatcher();
  5. const i18n = getContext('i18n');
  6. export let admin = false;
  7. export let params = {
  8. // Advanced
  9. seed: null,
  10. stop: null,
  11. temperature: null,
  12. frequency_penalty: null,
  13. repeat_last_n: null,
  14. mirostat: null,
  15. mirostat_eta: null,
  16. mirostat_tau: null,
  17. top_k: null,
  18. top_p: null,
  19. tfs_z: null,
  20. num_ctx: null,
  21. num_batch: null,
  22. num_keep: null,
  23. max_tokens: null,
  24. use_mmap: null,
  25. use_mlock: null,
  26. num_thread: null,
  27. template: null
  28. };
  29. let customFieldName = '';
  30. let customFieldValue = '';
  31. $: if (params) {
  32. dispatch('change', params);
  33. }
  34. </script>
  35. <div class=" space-y-1 text-xs">
  36. <div class=" py-0.5 w-full justify-between">
  37. <div class="flex w-full justify-between">
  38. <div class=" self-center text-xs font-medium">{$i18n.t('Seed')}</div>
  39. <button
  40. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  41. type="button"
  42. on:click={() => {
  43. params.seed = (params?.seed ?? null) === null ? 0 : null;
  44. }}
  45. >
  46. {#if (params?.seed ?? null) === null}
  47. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  48. {:else}
  49. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  50. {/if}
  51. </button>
  52. </div>
  53. {#if (params?.seed ?? null) !== null}
  54. <div class="flex mt-0.5 space-x-2">
  55. <div class=" flex-1">
  56. <input
  57. class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
  58. type="number"
  59. placeholder="Enter Seed"
  60. bind:value={params.seed}
  61. autocomplete="off"
  62. min="0"
  63. />
  64. </div>
  65. </div>
  66. {/if}
  67. </div>
  68. <div class=" py-0.5 w-full justify-between">
  69. <div class="flex w-full justify-between">
  70. <div class=" self-center text-xs font-medium">{$i18n.t('Stop Sequence')}</div>
  71. <button
  72. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  73. type="button"
  74. on:click={() => {
  75. params.stop = (params?.stop ?? null) === null ? '' : null;
  76. }}
  77. >
  78. {#if (params?.stop ?? null) === null}
  79. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  80. {:else}
  81. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  82. {/if}
  83. </button>
  84. </div>
  85. {#if (params?.stop ?? null) !== null}
  86. <div class="flex mt-0.5 space-x-2">
  87. <div class=" flex-1">
  88. <input
  89. class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
  90. type="text"
  91. placeholder={$i18n.t('Enter stop sequence')}
  92. bind:value={params.stop}
  93. autocomplete="off"
  94. />
  95. </div>
  96. </div>
  97. {/if}
  98. </div>
  99. <div class=" py-0.5 w-full justify-between">
  100. <div class="flex w-full justify-between">
  101. <div class=" self-center text-xs font-medium">{$i18n.t('Temperature')}</div>
  102. <button
  103. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  104. type="button"
  105. on:click={() => {
  106. params.temperature = (params?.temperature ?? null) === null ? 0.8 : null;
  107. }}
  108. >
  109. {#if (params?.temperature ?? null) === null}
  110. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  111. {:else}
  112. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  113. {/if}
  114. </button>
  115. </div>
  116. {#if (params?.temperature ?? null) !== null}
  117. <div class="flex mt-0.5 space-x-2">
  118. <div class=" flex-1">
  119. <input
  120. id="steps-range"
  121. type="range"
  122. min="0"
  123. max="1"
  124. step="0.05"
  125. bind:value={params.temperature}
  126. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  127. />
  128. </div>
  129. <div>
  130. <input
  131. bind:value={params.temperature}
  132. type="number"
  133. class=" bg-transparent text-center w-14"
  134. min="0"
  135. max="1"
  136. step="any"
  137. />
  138. </div>
  139. </div>
  140. {/if}
  141. </div>
  142. <div class=" py-0.5 w-full justify-between">
  143. <div class="flex w-full justify-between">
  144. <div class=" self-center text-xs font-medium">{$i18n.t('Mirostat')}</div>
  145. <button
  146. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  147. type="button"
  148. on:click={() => {
  149. params.mirostat = (params?.mirostat ?? null) === null ? 0 : null;
  150. }}
  151. >
  152. {#if (params?.mirostat ?? null) === null}
  153. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  154. {:else}
  155. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  156. {/if}
  157. </button>
  158. </div>
  159. {#if (params?.mirostat ?? null) !== null}
  160. <div class="flex mt-0.5 space-x-2">
  161. <div class=" flex-1">
  162. <input
  163. id="steps-range"
  164. type="range"
  165. min="0"
  166. max="2"
  167. step="1"
  168. bind:value={params.mirostat}
  169. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  170. />
  171. </div>
  172. <div>
  173. <input
  174. bind:value={params.mirostat}
  175. type="number"
  176. class=" bg-transparent text-center w-14"
  177. min="0"
  178. max="2"
  179. step="1"
  180. />
  181. </div>
  182. </div>
  183. {/if}
  184. </div>
  185. <div class=" py-0.5 w-full justify-between">
  186. <div class="flex w-full justify-between">
  187. <div class=" self-center text-xs font-medium">{$i18n.t('Mirostat Eta')}</div>
  188. <button
  189. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  190. type="button"
  191. on:click={() => {
  192. params.mirostat_eta = (params?.mirostat_eta ?? null) === null ? 0.1 : null;
  193. }}
  194. >
  195. {#if (params?.mirostat_eta ?? null) === null}
  196. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  197. {:else}
  198. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  199. {/if}
  200. </button>
  201. </div>
  202. {#if (params?.mirostat_eta ?? null) !== null}
  203. <div class="flex mt-0.5 space-x-2">
  204. <div class=" flex-1">
  205. <input
  206. id="steps-range"
  207. type="range"
  208. min="0"
  209. max="1"
  210. step="0.05"
  211. bind:value={params.mirostat_eta}
  212. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  213. />
  214. </div>
  215. <div>
  216. <input
  217. bind:value={params.mirostat_eta}
  218. type="number"
  219. class=" bg-transparent text-center w-14"
  220. min="0"
  221. max="1"
  222. step="any"
  223. />
  224. </div>
  225. </div>
  226. {/if}
  227. </div>
  228. <div class=" py-0.5 w-full justify-between">
  229. <div class="flex w-full justify-between">
  230. <div class=" self-center text-xs font-medium">{$i18n.t('Mirostat Tau')}</div>
  231. <button
  232. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  233. type="button"
  234. on:click={() => {
  235. params.mirostat_tau = (params?.mirostat_tau ?? null) === null ? 5.0 : null;
  236. }}
  237. >
  238. {#if (params?.mirostat_tau ?? null) === null}
  239. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  240. {:else}
  241. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  242. {/if}
  243. </button>
  244. </div>
  245. {#if (params?.mirostat_tau ?? null) !== null}
  246. <div class="flex mt-0.5 space-x-2">
  247. <div class=" flex-1">
  248. <input
  249. id="steps-range"
  250. type="range"
  251. min="0"
  252. max="10"
  253. step="0.5"
  254. bind:value={params.mirostat_tau}
  255. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  256. />
  257. </div>
  258. <div>
  259. <input
  260. bind:value={params.mirostat_tau}
  261. type="number"
  262. class=" bg-transparent text-center w-14"
  263. min="0"
  264. max="10"
  265. step="any"
  266. />
  267. </div>
  268. </div>
  269. {/if}
  270. </div>
  271. <div class=" py-0.5 w-full justify-between">
  272. <div class="flex w-full justify-between">
  273. <div class=" self-center text-xs font-medium">{$i18n.t('Top K')}</div>
  274. <button
  275. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  276. type="button"
  277. on:click={() => {
  278. params.top_k = (params?.top_k ?? null) === null ? 40 : null;
  279. }}
  280. >
  281. {#if (params?.top_k ?? null) === null}
  282. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  283. {:else}
  284. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  285. {/if}
  286. </button>
  287. </div>
  288. {#if (params?.top_k ?? null) !== null}
  289. <div class="flex mt-0.5 space-x-2">
  290. <div class=" flex-1">
  291. <input
  292. id="steps-range"
  293. type="range"
  294. min="0"
  295. max="100"
  296. step="0.5"
  297. bind:value={params.top_k}
  298. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  299. />
  300. </div>
  301. <div>
  302. <input
  303. bind:value={params.top_k}
  304. type="number"
  305. class=" bg-transparent text-center w-14"
  306. min="0"
  307. max="100"
  308. step="any"
  309. />
  310. </div>
  311. </div>
  312. {/if}
  313. </div>
  314. <div class=" py-0.5 w-full justify-between">
  315. <div class="flex w-full justify-between">
  316. <div class=" self-center text-xs font-medium">{$i18n.t('Top P')}</div>
  317. <button
  318. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  319. type="button"
  320. on:click={() => {
  321. params.top_p = (params?.top_p ?? null) === null ? 0.9 : null;
  322. }}
  323. >
  324. {#if (params?.top_p ?? null) === null}
  325. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  326. {:else}
  327. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  328. {/if}
  329. </button>
  330. </div>
  331. {#if (params?.top_p ?? null) !== null}
  332. <div class="flex mt-0.5 space-x-2">
  333. <div class=" flex-1">
  334. <input
  335. id="steps-range"
  336. type="range"
  337. min="0"
  338. max="1"
  339. step="0.05"
  340. bind:value={params.top_p}
  341. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  342. />
  343. </div>
  344. <div>
  345. <input
  346. bind:value={params.top_p}
  347. type="number"
  348. class=" bg-transparent text-center w-14"
  349. min="0"
  350. max="1"
  351. step="any"
  352. />
  353. </div>
  354. </div>
  355. {/if}
  356. </div>
  357. <div class=" py-0.5 w-full justify-between">
  358. <div class="flex w-full justify-between">
  359. <div class=" self-center text-xs font-medium">{$i18n.t('Frequency Penalty')}</div>
  360. <button
  361. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  362. type="button"
  363. on:click={() => {
  364. params.frequency_penalty = (params?.frequency_penalty ?? null) === null ? 1.1 : null;
  365. }}
  366. >
  367. {#if (params?.frequency_penalty ?? null) === null}
  368. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  369. {:else}
  370. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  371. {/if}
  372. </button>
  373. </div>
  374. {#if (params?.frequency_penalty ?? null) !== null}
  375. <div class="flex mt-0.5 space-x-2">
  376. <div class=" flex-1">
  377. <input
  378. id="steps-range"
  379. type="range"
  380. min="0"
  381. max="2"
  382. step="0.05"
  383. bind:value={params.frequency_penalty}
  384. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  385. />
  386. </div>
  387. <div>
  388. <input
  389. bind:value={params.frequency_penalty}
  390. type="number"
  391. class=" bg-transparent text-center w-14"
  392. min="0"
  393. max="2"
  394. step="any"
  395. />
  396. </div>
  397. </div>
  398. {/if}
  399. </div>
  400. <div class=" py-0.5 w-full justify-between">
  401. <div class="flex w-full justify-between">
  402. <div class=" self-center text-xs font-medium">{$i18n.t('Repeat Last N')}</div>
  403. <button
  404. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  405. type="button"
  406. on:click={() => {
  407. params.repeat_last_n = (params?.repeat_last_n ?? null) === null ? 64 : null;
  408. }}
  409. >
  410. {#if (params?.repeat_last_n ?? null) === null}
  411. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  412. {:else}
  413. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  414. {/if}
  415. </button>
  416. </div>
  417. {#if (params?.repeat_last_n ?? null) !== null}
  418. <div class="flex mt-0.5 space-x-2">
  419. <div class=" flex-1">
  420. <input
  421. id="steps-range"
  422. type="range"
  423. min="-1"
  424. max="128"
  425. step="1"
  426. bind:value={params.repeat_last_n}
  427. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  428. />
  429. </div>
  430. <div>
  431. <input
  432. bind:value={params.repeat_last_n}
  433. type="number"
  434. class=" bg-transparent text-center w-14"
  435. min="-1"
  436. max="128"
  437. step="1"
  438. />
  439. </div>
  440. </div>
  441. {/if}
  442. </div>
  443. <div class=" py-0.5 w-full justify-between">
  444. <div class="flex w-full justify-between">
  445. <div class=" self-center text-xs font-medium">{$i18n.t('Tfs Z')}</div>
  446. <button
  447. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  448. type="button"
  449. on:click={() => {
  450. params.tfs_z = (params?.tfs_z ?? null) === null ? 1 : null;
  451. }}
  452. >
  453. {#if (params?.tfs_z ?? null) === null}
  454. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  455. {:else}
  456. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  457. {/if}
  458. </button>
  459. </div>
  460. {#if (params?.tfs_z ?? null) !== null}
  461. <div class="flex mt-0.5 space-x-2">
  462. <div class=" flex-1">
  463. <input
  464. id="steps-range"
  465. type="range"
  466. min="0"
  467. max="2"
  468. step="0.05"
  469. bind:value={params.tfs_z}
  470. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  471. />
  472. </div>
  473. <div>
  474. <input
  475. bind:value={params.tfs_z}
  476. type="number"
  477. class=" bg-transparent text-center w-14"
  478. min="0"
  479. max="2"
  480. step="any"
  481. />
  482. </div>
  483. </div>
  484. {/if}
  485. </div>
  486. <div class=" py-0.5 w-full justify-between">
  487. <div class="flex w-full justify-between">
  488. <div class=" self-center text-xs font-medium">{$i18n.t('Context Length')}</div>
  489. <button
  490. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  491. type="button"
  492. on:click={() => {
  493. params.num_ctx = (params?.num_ctx ?? null) === null ? 2048 : null;
  494. }}
  495. >
  496. {#if (params?.num_ctx ?? null) === null}
  497. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  498. {:else}
  499. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  500. {/if}
  501. </button>
  502. </div>
  503. {#if (params?.num_ctx ?? null) !== null}
  504. <div class="flex mt-0.5 space-x-2">
  505. <div class=" flex-1">
  506. <input
  507. id="steps-range"
  508. type="range"
  509. min="-1"
  510. max="10240000"
  511. step="1"
  512. bind:value={params.num_ctx}
  513. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  514. />
  515. </div>
  516. <div class="">
  517. <input
  518. bind:value={params.num_ctx}
  519. type="number"
  520. class=" bg-transparent text-center w-14"
  521. min="-1"
  522. step="1"
  523. />
  524. </div>
  525. </div>
  526. {/if}
  527. </div>
  528. <div class=" py-0.5 w-full justify-between">
  529. <div class="flex w-full justify-between">
  530. <div class=" self-center text-xs font-medium">{$i18n.t('Batch Size (num_batch)')}</div>
  531. <button
  532. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  533. type="button"
  534. on:click={() => {
  535. params.num_batch = (params?.num_batch ?? null) === null ? 512 : null;
  536. }}
  537. >
  538. {#if (params?.num_batch ?? null) === null}
  539. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  540. {:else}
  541. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  542. {/if}
  543. </button>
  544. </div>
  545. {#if (params?.num_batch ?? null) !== null}
  546. <div class="flex mt-0.5 space-x-2">
  547. <div class=" flex-1">
  548. <input
  549. id="steps-range"
  550. type="range"
  551. min="256"
  552. max="8192"
  553. step="256"
  554. bind:value={params.num_batch}
  555. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  556. />
  557. </div>
  558. <div class="">
  559. <input
  560. bind:value={params.num_batch}
  561. type="number"
  562. class=" bg-transparent text-center w-14"
  563. min="256"
  564. step="256"
  565. />
  566. </div>
  567. </div>
  568. {/if}
  569. </div>
  570. <div class=" py-0.5 w-full justify-between">
  571. <div class="flex w-full justify-between">
  572. <div class=" self-center text-xs font-medium">
  573. {$i18n.t('Tokens To Keep On Context Refresh (num_keep)')}
  574. </div>
  575. <button
  576. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  577. type="button"
  578. on:click={() => {
  579. params.num_keep = (params?.num_keep ?? null) === null ? 24 : null;
  580. }}
  581. >
  582. {#if (params?.num_keep ?? null) === null}
  583. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  584. {:else}
  585. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  586. {/if}
  587. </button>
  588. </div>
  589. {#if (params?.num_keep ?? null) !== null}
  590. <div class="flex mt-0.5 space-x-2">
  591. <div class=" flex-1">
  592. <input
  593. id="steps-range"
  594. type="range"
  595. min="-1"
  596. max="10240000"
  597. step="1"
  598. bind:value={params.num_keep}
  599. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  600. />
  601. </div>
  602. <div class="">
  603. <input
  604. bind:value={params.num_keep}
  605. type="number"
  606. class=" bg-transparent text-center w-14"
  607. min="-1"
  608. step="1"
  609. />
  610. </div>
  611. </div>
  612. {/if}
  613. </div>
  614. <div class=" py-0.5 w-full justify-between">
  615. <div class="flex w-full justify-between">
  616. <div class=" self-center text-xs font-medium">{$i18n.t('Max Tokens (num_predict)')}</div>
  617. <button
  618. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  619. type="button"
  620. on:click={() => {
  621. params.max_tokens = (params?.max_tokens ?? null) === null ? 128 : null;
  622. }}
  623. >
  624. {#if (params?.max_tokens ?? null) === null}
  625. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  626. {:else}
  627. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  628. {/if}
  629. </button>
  630. </div>
  631. {#if (params?.max_tokens ?? null) !== null}
  632. <div class="flex mt-0.5 space-x-2">
  633. <div class=" flex-1">
  634. <input
  635. id="steps-range"
  636. type="range"
  637. min="-2"
  638. max="16000"
  639. step="1"
  640. bind:value={params.max_tokens}
  641. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  642. />
  643. </div>
  644. <div class="">
  645. <input
  646. bind:value={params.max_tokens}
  647. type="number"
  648. class=" bg-transparent text-center w-14"
  649. min="-2"
  650. max="16000"
  651. step="1"
  652. />
  653. </div>
  654. </div>
  655. {/if}
  656. </div>
  657. {#if admin}
  658. <div class=" py-0.5 w-full justify-between">
  659. <div class="flex w-full justify-between">
  660. <div class=" self-center text-xs font-medium">{$i18n.t('use_mmap (Ollama)')}</div>
  661. <button
  662. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  663. type="button"
  664. on:click={() => {
  665. params.use_mmap = (params?.use_mmap ?? null) === null ? true : null;
  666. }}
  667. >
  668. {#if (params?.use_mmap ?? null) === null}
  669. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  670. {:else}
  671. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  672. {/if}
  673. </button>
  674. </div>
  675. {#if (params?.use_mmap ?? null) !== null}
  676. <div class="flex justify-between items-center mt-1">
  677. <div class="text-xs text-gray-500">
  678. {params.use_mmap ? 'Enabled' : 'Disabled'}
  679. </div>
  680. <div class=" pr-2">
  681. <Switch bind:state={params.use_mmap} />
  682. </div>
  683. </div>
  684. {/if}
  685. </div>
  686. <div class=" py-0.5 w-full justify-between">
  687. <div class="flex w-full justify-between">
  688. <div class=" self-center text-xs font-medium">{$i18n.t('use_mlock (Ollama)')}</div>
  689. <button
  690. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  691. type="button"
  692. on:click={() => {
  693. params.use_mlock = (params?.use_mlock ?? null) === null ? true : null;
  694. }}
  695. >
  696. {#if (params?.use_mlock ?? null) === null}
  697. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  698. {:else}
  699. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  700. {/if}
  701. </button>
  702. </div>
  703. {#if (params?.use_mlock ?? null) !== null}
  704. <div class="flex justify-between items-center mt-1">
  705. <div class="text-xs text-gray-500">
  706. {params.use_mlock ? 'Enabled' : 'Disabled'}
  707. </div>
  708. <div class=" pr-2">
  709. <Switch bind:state={params.use_mlock} />
  710. </div>
  711. </div>
  712. {/if}
  713. </div>
  714. <div class=" py-0.5 w-full justify-between">
  715. <div class="flex w-full justify-between">
  716. <div class=" self-center text-xs font-medium">{$i18n.t('num_thread (Ollama)')}</div>
  717. <button
  718. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  719. type="button"
  720. on:click={() => {
  721. params.num_thread = (params?.num_thread ?? null) === null ? 2 : null;
  722. }}
  723. >
  724. {#if (params?.num_thread ?? null) === null}
  725. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  726. {:else}
  727. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  728. {/if}
  729. </button>
  730. </div>
  731. {#if (params?.num_thread ?? null) !== null}
  732. <div class="flex mt-0.5 space-x-2">
  733. <div class=" flex-1">
  734. <input
  735. id="steps-range"
  736. type="range"
  737. min="1"
  738. max="256"
  739. step="1"
  740. bind:value={params.num_thread}
  741. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  742. />
  743. </div>
  744. <div class="">
  745. <input
  746. bind:value={params.num_thread}
  747. type="number"
  748. class=" bg-transparent text-center w-14"
  749. min="1"
  750. max="256"
  751. step="1"
  752. />
  753. </div>
  754. </div>
  755. {/if}
  756. </div>
  757. <!-- <div class=" py-0.5 w-full justify-between">
  758. <div class="flex w-full justify-between">
  759. <div class=" self-center text-xs font-medium">{$i18n.t('Template')}</div>
  760. <button
  761. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  762. type="button"
  763. on:click={() => {
  764. params.template = (params?.template ?? null) === null ? '' : null;
  765. }}
  766. >
  767. {#if (params?.template ?? null) === null}
  768. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  769. {:else}
  770. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  771. {/if}
  772. </button>
  773. </div>
  774. {#if (params?.template ?? null) !== null}
  775. <div class="flex mt-0.5 space-x-2">
  776. <div class=" flex-1">
  777. <textarea
  778. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg -mb-1"
  779. placeholder="Write your model template content here"
  780. rows="4"
  781. bind:value={params.template}
  782. />
  783. </div>
  784. </div>
  785. {/if}
  786. </div> -->
  787. {/if}
  788. </div>