1
0

AdvancedParams.svelte 44 KB

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