Advanced.svelte 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <script lang="ts">
  2. export let options = {
  3. // Advanced
  4. seed: 0,
  5. stop: '',
  6. temperature: '',
  7. repeat_penalty: '',
  8. repeat_last_n: '',
  9. mirostat: '',
  10. mirostat_eta: '',
  11. mirostat_tau: '',
  12. top_k: '',
  13. top_p: '',
  14. tfs_z: '',
  15. num_ctx: '',
  16. num_predict: ''
  17. };
  18. </script>
  19. <div class=" space-y-3 text-xs">
  20. <div>
  21. <div class=" py-0.5 flex w-full justify-between">
  22. <div class=" w-20 text-xs font-medium self-center">Seed</div>
  23. <div class=" flex-1 self-center">
  24. <input
  25. class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
  26. type="number"
  27. placeholder="Enter Seed"
  28. bind:value={options.seed}
  29. autocomplete="off"
  30. min="0"
  31. />
  32. </div>
  33. </div>
  34. </div>
  35. <div>
  36. <div class=" py-0.5 flex w-full justify-between">
  37. <div class=" w-20 text-xs font-medium self-center">Stop Sequence</div>
  38. <div class=" flex-1 self-center">
  39. <input
  40. class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
  41. type="text"
  42. placeholder="Enter Stop Sequence"
  43. bind:value={options.stop}
  44. autocomplete="off"
  45. />
  46. </div>
  47. </div>
  48. </div>
  49. <div class=" py-0.5 w-full justify-between">
  50. <div class="flex w-full justify-between">
  51. <div class=" self-center text-xs font-medium">Temperature</div>
  52. <button
  53. class="p-1 px-3 text-xs flex rounded transition"
  54. type="button"
  55. on:click={() => {
  56. options.temperature = options.temperature === '' ? 0.8 : '';
  57. }}
  58. >
  59. {#if options.temperature === ''}
  60. <span class="ml-2 self-center"> Default </span>
  61. {:else}
  62. <span class="ml-2 self-center"> Custom </span>
  63. {/if}
  64. </button>
  65. </div>
  66. {#if options.temperature !== ''}
  67. <div class="flex mt-0.5 space-x-2">
  68. <div class=" flex-1">
  69. <input
  70. id="steps-range"
  71. type="range"
  72. min="0"
  73. max="1"
  74. step="0.05"
  75. bind:value={options.temperature}
  76. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  77. />
  78. </div>
  79. <div>
  80. <input
  81. bind:value={options.temperature}
  82. type="number"
  83. class=" bg-transparent text-center w-14"
  84. min="0"
  85. max="1"
  86. step="0.05"
  87. />
  88. </div>
  89. </div>
  90. {/if}
  91. </div>
  92. <div class=" py-0.5 w-full justify-between">
  93. <div class="flex w-full justify-between">
  94. <div class=" self-center text-xs font-medium">Mirostat</div>
  95. <button
  96. class="p-1 px-3 text-xs flex rounded transition"
  97. type="button"
  98. on:click={() => {
  99. options.mirostat = options.mirostat === '' ? 0 : '';
  100. }}
  101. >
  102. {#if options.mirostat === ''}
  103. <span class="ml-2 self-center"> Default </span>
  104. {:else}
  105. <span class="ml-2 self-center"> Custom </span>
  106. {/if}
  107. </button>
  108. </div>
  109. {#if options.mirostat !== ''}
  110. <div class="flex mt-0.5 space-x-2">
  111. <div class=" flex-1">
  112. <input
  113. id="steps-range"
  114. type="range"
  115. min="0"
  116. max="2"
  117. step="1"
  118. bind:value={options.mirostat}
  119. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  120. />
  121. </div>
  122. <div>
  123. <input
  124. bind:value={options.mirostat}
  125. type="number"
  126. class=" bg-transparent text-center w-14"
  127. min="0"
  128. max="2"
  129. step="1"
  130. />
  131. </div>
  132. </div>
  133. {/if}
  134. </div>
  135. <div class=" py-0.5 w-full justify-between">
  136. <div class="flex w-full justify-between">
  137. <div class=" self-center text-xs font-medium">Mirostat Eta</div>
  138. <button
  139. class="p-1 px-3 text-xs flex rounded transition"
  140. type="button"
  141. on:click={() => {
  142. options.mirostat_eta = options.mirostat_eta === '' ? 0.1 : '';
  143. }}
  144. >
  145. {#if options.mirostat_eta === ''}
  146. <span class="ml-2 self-center"> Default </span>
  147. {:else}
  148. <span class="ml-2 self-center"> Custom </span>
  149. {/if}
  150. </button>
  151. </div>
  152. {#if options.mirostat_eta !== ''}
  153. <div class="flex mt-0.5 space-x-2">
  154. <div class=" flex-1">
  155. <input
  156. id="steps-range"
  157. type="range"
  158. min="0"
  159. max="1"
  160. step="0.05"
  161. bind:value={options.mirostat_eta}
  162. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  163. />
  164. </div>
  165. <div>
  166. <input
  167. bind:value={options.mirostat_eta}
  168. type="number"
  169. class=" bg-transparent text-center w-14"
  170. min="0"
  171. max="1"
  172. step="0.05"
  173. />
  174. </div>
  175. </div>
  176. {/if}
  177. </div>
  178. <div class=" py-0.5 w-full justify-between">
  179. <div class="flex w-full justify-between">
  180. <div class=" self-center text-xs font-medium">Mirostat Tau</div>
  181. <button
  182. class="p-1 px-3 text-xs flex rounded transition"
  183. type="button"
  184. on:click={() => {
  185. options.mirostat_tau = options.mirostat_tau === '' ? 5.0 : '';
  186. }}
  187. >
  188. {#if options.mirostat_tau === ''}
  189. <span class="ml-2 self-center"> Default </span>
  190. {:else}
  191. <span class="ml-2 self-center"> Custom </span>
  192. {/if}
  193. </button>
  194. </div>
  195. {#if options.mirostat_tau !== ''}
  196. <div class="flex mt-0.5 space-x-2">
  197. <div class=" flex-1">
  198. <input
  199. id="steps-range"
  200. type="range"
  201. min="0"
  202. max="10"
  203. step="0.5"
  204. bind:value={options.mirostat_tau}
  205. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  206. />
  207. </div>
  208. <div>
  209. <input
  210. bind:value={options.mirostat_tau}
  211. type="number"
  212. class=" bg-transparent text-center w-14"
  213. min="0"
  214. max="10"
  215. step="0.5"
  216. />
  217. </div>
  218. </div>
  219. {/if}
  220. </div>
  221. <div class=" py-0.5 w-full justify-between">
  222. <div class="flex w-full justify-between">
  223. <div class=" self-center text-xs font-medium">Top K</div>
  224. <button
  225. class="p-1 px-3 text-xs flex rounded transition"
  226. type="button"
  227. on:click={() => {
  228. options.top_k = options.top_k === '' ? 40 : '';
  229. }}
  230. >
  231. {#if options.top_k === ''}
  232. <span class="ml-2 self-center"> Default </span>
  233. {:else}
  234. <span class="ml-2 self-center"> Custom </span>
  235. {/if}
  236. </button>
  237. </div>
  238. {#if options.top_k !== ''}
  239. <div class="flex mt-0.5 space-x-2">
  240. <div class=" flex-1">
  241. <input
  242. id="steps-range"
  243. type="range"
  244. min="0"
  245. max="100"
  246. step="0.5"
  247. bind:value={options.top_k}
  248. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  249. />
  250. </div>
  251. <div>
  252. <input
  253. bind:value={options.top_k}
  254. type="number"
  255. class=" bg-transparent text-center w-14"
  256. min="0"
  257. max="100"
  258. step="0.5"
  259. />
  260. </div>
  261. </div>
  262. {/if}
  263. </div>
  264. <div class=" py-0.5 w-full justify-between">
  265. <div class="flex w-full justify-between">
  266. <div class=" self-center text-xs font-medium">Top P</div>
  267. <button
  268. class="p-1 px-3 text-xs flex rounded transition"
  269. type="button"
  270. on:click={() => {
  271. options.top_p = options.top_p === '' ? 0.9 : '';
  272. }}
  273. >
  274. {#if options.top_p === ''}
  275. <span class="ml-2 self-center"> Default </span>
  276. {:else}
  277. <span class="ml-2 self-center"> Custom </span>
  278. {/if}
  279. </button>
  280. </div>
  281. {#if options.top_p !== ''}
  282. <div class="flex mt-0.5 space-x-2">
  283. <div class=" flex-1">
  284. <input
  285. id="steps-range"
  286. type="range"
  287. min="0"
  288. max="1"
  289. step="0.05"
  290. bind:value={options.top_p}
  291. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  292. />
  293. </div>
  294. <div>
  295. <input
  296. bind:value={options.top_p}
  297. type="number"
  298. class=" bg-transparent text-center w-14"
  299. min="0"
  300. max="1"
  301. step="0.05"
  302. />
  303. </div>
  304. </div>
  305. {/if}
  306. </div>
  307. <div class=" py-0.5 w-full justify-between">
  308. <div class="flex w-full justify-between">
  309. <div class=" self-center text-xs font-medium">Repeat Penalty</div>
  310. <button
  311. class="p-1 px-3 text-xs flex rounded transition"
  312. type="button"
  313. on:click={() => {
  314. options.repeat_penalty = options.repeat_penalty === '' ? 1.1 : '';
  315. }}
  316. >
  317. {#if options.repeat_penalty === ''}
  318. <span class="ml-2 self-center"> Default </span>
  319. {:else}
  320. <span class="ml-2 self-center"> Custom </span>
  321. {/if}
  322. </button>
  323. </div>
  324. {#if options.repeat_penalty !== ''}
  325. <div class="flex mt-0.5 space-x-2">
  326. <div class=" flex-1">
  327. <input
  328. id="steps-range"
  329. type="range"
  330. min="0"
  331. max="2"
  332. step="0.05"
  333. bind:value={options.repeat_penalty}
  334. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  335. />
  336. </div>
  337. <div>
  338. <input
  339. bind:value={options.repeat_penalty}
  340. type="number"
  341. class=" bg-transparent text-center w-14"
  342. min="0"
  343. max="2"
  344. step="0.05"
  345. />
  346. </div>
  347. </div>
  348. {/if}
  349. </div>
  350. <div class=" py-0.5 w-full justify-between">
  351. <div class="flex w-full justify-between">
  352. <div class=" self-center text-xs font-medium">Repeat Last N</div>
  353. <button
  354. class="p-1 px-3 text-xs flex rounded transition"
  355. type="button"
  356. on:click={() => {
  357. options.repeat_last_n = options.repeat_last_n === '' ? 64 : '';
  358. }}
  359. >
  360. {#if options.repeat_last_n === ''}
  361. <span class="ml-2 self-center"> Default </span>
  362. {:else}
  363. <span class="ml-2 self-center"> Custom </span>
  364. {/if}
  365. </button>
  366. </div>
  367. {#if options.repeat_last_n !== ''}
  368. <div class="flex mt-0.5 space-x-2">
  369. <div class=" flex-1">
  370. <input
  371. id="steps-range"
  372. type="range"
  373. min="-1"
  374. max="128"
  375. step="1"
  376. bind:value={options.repeat_last_n}
  377. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  378. />
  379. </div>
  380. <div>
  381. <input
  382. bind:value={options.repeat_last_n}
  383. type="number"
  384. class=" bg-transparent text-center w-14"
  385. min="-1"
  386. max="128"
  387. step="1"
  388. />
  389. </div>
  390. </div>
  391. {/if}
  392. </div>
  393. <div class=" py-0.5 w-full justify-between">
  394. <div class="flex w-full justify-between">
  395. <div class=" self-center text-xs font-medium">Tfs Z</div>
  396. <button
  397. class="p-1 px-3 text-xs flex rounded transition"
  398. type="button"
  399. on:click={() => {
  400. options.tfs_z = options.tfs_z === '' ? 1 : '';
  401. }}
  402. >
  403. {#if options.tfs_z === ''}
  404. <span class="ml-2 self-center"> Default </span>
  405. {:else}
  406. <span class="ml-2 self-center"> Custom </span>
  407. {/if}
  408. </button>
  409. </div>
  410. {#if options.tfs_z !== ''}
  411. <div class="flex mt-0.5 space-x-2">
  412. <div class=" flex-1">
  413. <input
  414. id="steps-range"
  415. type="range"
  416. min="0"
  417. max="2"
  418. step="0.05"
  419. bind:value={options.tfs_z}
  420. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  421. />
  422. </div>
  423. <div>
  424. <input
  425. bind:value={options.tfs_z}
  426. type="number"
  427. class=" bg-transparent text-center w-14"
  428. min="0"
  429. max="2"
  430. step="0.05"
  431. />
  432. </div>
  433. </div>
  434. {/if}
  435. </div>
  436. <div class=" py-0.5 w-full justify-between">
  437. <div class="flex w-full justify-between">
  438. <div class=" self-center text-xs font-medium">Context Length</div>
  439. <button
  440. class="p-1 px-3 text-xs flex rounded transition"
  441. type="button"
  442. on:click={() => {
  443. options.num_ctx = options.num_ctx === '' ? 2048 : '';
  444. }}
  445. >
  446. {#if options.num_ctx === ''}
  447. <span class="ml-2 self-center"> Default </span>
  448. {:else}
  449. <span class="ml-2 self-center"> Custom </span>
  450. {/if}
  451. </button>
  452. </div>
  453. {#if options.num_ctx !== ''}
  454. <div class="flex mt-0.5 space-x-2">
  455. <div class=" flex-1">
  456. <input
  457. id="steps-range"
  458. type="range"
  459. min="1"
  460. max="16000"
  461. step="1"
  462. bind:value={options.num_ctx}
  463. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  464. />
  465. </div>
  466. <div class="">
  467. <input
  468. bind:value={options.num_ctx}
  469. type="number"
  470. class=" bg-transparent text-center w-14"
  471. min="1"
  472. max="16000"
  473. step="1"
  474. />
  475. </div>
  476. </div>
  477. {/if}
  478. </div>
  479. <div class=" py-0.5 w-full justify-between">
  480. <div class="flex w-full justify-between">
  481. <div class=" self-center text-xs font-medium">Max Tokens</div>
  482. <button
  483. class="p-1 px-3 text-xs flex rounded transition"
  484. type="button"
  485. on:click={() => {
  486. options.num_predict = options.num_predict === '' ? 128 : '';
  487. }}
  488. >
  489. {#if options.num_predict === ''}
  490. <span class="ml-2 self-center"> Default </span>
  491. {:else}
  492. <span class="ml-2 self-center"> Custom </span>
  493. {/if}
  494. </button>
  495. </div>
  496. {#if options.num_predict !== ''}
  497. <div class="flex mt-0.5 space-x-2">
  498. <div class=" flex-1">
  499. <input
  500. id="steps-range"
  501. type="range"
  502. min="-2"
  503. max="16000"
  504. step="1"
  505. bind:value={options.num_predict}
  506. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  507. />
  508. </div>
  509. <div class="">
  510. <input
  511. bind:value={options.num_predict}
  512. type="number"
  513. class=" bg-transparent text-center w-14"
  514. min="-2"
  515. max="16000"
  516. step="1"
  517. />
  518. </div>
  519. </div>
  520. {/if}
  521. </div>
  522. </div>