+page.svelte 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. <script>
  2. import { v4 as uuidv4 } from 'uuid';
  3. import { toast } from 'svelte-sonner';
  4. import { goto } from '$app/navigation';
  5. import { settings, user, config, models, tools, functions } from '$lib/stores';
  6. import TurndownService from 'turndown';
  7. import { onMount, tick, getContext } from 'svelte';
  8. import { addNewModel, getModelById, getModelInfos } from '$lib/apis/models';
  9. import { getModels } from '$lib/apis';
  10. import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
  11. import Checkbox from '$lib/components/common/Checkbox.svelte';
  12. import Tags from '$lib/components/common/Tags.svelte';
  13. import Knowledge from '$lib/components/workspace/Models/Knowledge.svelte';
  14. import ToolsSelector from '$lib/components/workspace/Models/ToolsSelector.svelte';
  15. import { stringify } from 'postcss';
  16. import { parseFile } from '$lib/utils/characters';
  17. import FiltersSelector from '$lib/components/workspace/Models/FiltersSelector.svelte';
  18. const i18n = getContext('i18n');
  19. let filesInputElement;
  20. let inputFiles;
  21. let showAdvanced = false;
  22. let showPreview = false;
  23. let loading = false;
  24. let success = false;
  25. // ///////////
  26. // Model
  27. // ///////////
  28. let id = '';
  29. let name = '';
  30. let info = {
  31. id: '',
  32. base_model_id: null,
  33. name: '',
  34. meta: {
  35. profile_image_url: null,
  36. description: '',
  37. suggestion_prompts: [
  38. {
  39. content: ''
  40. }
  41. ]
  42. },
  43. params: {
  44. system: ''
  45. }
  46. };
  47. let params = {};
  48. let capabilities = {
  49. vision: true
  50. };
  51. let toolIds = [];
  52. let knowledge = [];
  53. let filterIds = [];
  54. $: if (name) {
  55. id = name
  56. .replace(/\s+/g, '-')
  57. .replace(/[^a-zA-Z0-9-]/g, '')
  58. .toLowerCase();
  59. }
  60. const addUsage = (base_model_id) => {
  61. const baseModel = $models.find((m) => m.id === base_model_id);
  62. if (baseModel) {
  63. if (baseModel.owned_by === 'openai') {
  64. capabilities.usage = baseModel.info?.meta?.capabilities?.usage ?? false;
  65. } else {
  66. delete capabilities.usage;
  67. }
  68. capabilities = capabilities;
  69. }
  70. };
  71. const submitHandler = async () => {
  72. loading = true;
  73. info.id = id;
  74. info.name = name;
  75. info.meta.capabilities = capabilities;
  76. if (knowledge.length > 0) {
  77. info.meta.knowledge = knowledge;
  78. } else {
  79. if (info.meta.knowledge) {
  80. delete info.meta.knowledge;
  81. }
  82. }
  83. if (toolIds.length > 0) {
  84. info.meta.toolIds = toolIds;
  85. } else {
  86. if (info.meta.toolIds) {
  87. delete info.meta.toolIds;
  88. }
  89. }
  90. if (filterIds.length > 0) {
  91. info.meta.filterIds = filterIds;
  92. } else {
  93. if (info.meta.filterIds) {
  94. delete info.meta.filterIds;
  95. }
  96. }
  97. info.params.stop = params.stop ? params.stop.split(',').filter((s) => s.trim()) : null;
  98. Object.keys(info.params).forEach((key) => {
  99. if (info.params[key] === '' || info.params[key] === null) {
  100. delete info.params[key];
  101. }
  102. });
  103. if ($models.find((m) => m.id === info.id)) {
  104. toast.error(
  105. `Error: A model with the ID '${info.id}' already exists. Please select a different ID to proceed.`
  106. );
  107. loading = false;
  108. success = false;
  109. return success;
  110. }
  111. if (info) {
  112. const res = await addNewModel(localStorage.token, {
  113. ...info,
  114. meta: {
  115. ...info.meta,
  116. profile_image_url: info.meta.profile_image_url ?? '/favicon.png',
  117. suggestion_prompts: info.meta.suggestion_prompts
  118. ? info.meta.suggestion_prompts.filter((prompt) => prompt.content !== '')
  119. : null
  120. },
  121. params: { ...info.params, ...params }
  122. });
  123. if (res) {
  124. await models.set(await getModels(localStorage.token));
  125. toast.success($i18n.t('Model created successfully!'));
  126. await goto('/workspace/models');
  127. }
  128. }
  129. loading = false;
  130. success = false;
  131. };
  132. const initModel = async (model) => {
  133. name = model.name;
  134. await tick();
  135. id = model.id;
  136. if (model.info.base_model_id) {
  137. const base_model = $models
  138. .filter((m) => !m?.preset)
  139. .find((m) =>
  140. [model.info.base_model_id, `${model.info.base_model_id}:latest`].includes(m.id)
  141. );
  142. console.log('base_model', base_model);
  143. if (!base_model) {
  144. model.info.base_model_id = null;
  145. } else if ($models.find((m) => m.id === `${model.info.base_model_id}:latest`)) {
  146. model.info.base_model_id = `${model.info.base_model_id}:latest`;
  147. }
  148. }
  149. params = { ...params, ...model?.info?.params };
  150. params.stop = params?.stop ? (params?.stop ?? []).join(',') : null;
  151. capabilities = { ...capabilities, ...(model?.info?.meta?.capabilities ?? {}) };
  152. toolIds = model?.info?.meta?.toolIds ?? [];
  153. if (model?.info?.meta?.filterIds) {
  154. filterIds = [...model?.info?.meta?.filterIds];
  155. }
  156. info = {
  157. ...info,
  158. ...model.info
  159. };
  160. console.log(info);
  161. };
  162. onMount(async () => {
  163. window.addEventListener('message', async (event) => {
  164. if (
  165. !['https://openwebui.com', 'https://www.openwebui.com', 'http://localhost:5173'].includes(
  166. event.origin
  167. )
  168. )
  169. return;
  170. const model = JSON.parse(event.data);
  171. console.log(model);
  172. initModel(model);
  173. });
  174. if (window.opener ?? false) {
  175. window.opener.postMessage('loaded', '*');
  176. }
  177. if (sessionStorage.model) {
  178. const model = JSON.parse(sessionStorage.model);
  179. sessionStorage.removeItem('model');
  180. console.log(model);
  181. initModel(model);
  182. }
  183. });
  184. </script>
  185. <div class="w-full max-h-full">
  186. <input
  187. bind:this={filesInputElement}
  188. bind:files={inputFiles}
  189. type="file"
  190. hidden
  191. accept="image/*"
  192. on:change={() => {
  193. let reader = new FileReader();
  194. reader.onload = async (event) => {
  195. let originalImageUrl = `${event.target.result}`;
  196. let character = await parseFile(inputFiles[0]).catch((error) => {
  197. return null;
  198. });
  199. console.log(character);
  200. if (character && character.character) {
  201. character = character.character;
  202. console.log(character);
  203. name = character.name;
  204. const pattern = /<\/?[a-z][\s\S]*>/i;
  205. if (character.summary.match(pattern)) {
  206. const turndownService = new TurndownService();
  207. info.meta.description = turndownService.turndown(character.summary);
  208. } else {
  209. info.meta.description = character.summary;
  210. }
  211. info.params.system = `Personality: ${character.personality}${
  212. character?.scenario ? `\nScenario: ${character.scenario}` : ''
  213. }${character?.greeting ? `\First Message: ${character.greeting}` : ''}${
  214. character?.examples ? `\nExamples: ${character.examples}` : ''
  215. }`;
  216. }
  217. const img = new Image();
  218. img.src = originalImageUrl;
  219. img.onload = function () {
  220. const canvas = document.createElement('canvas');
  221. const ctx = canvas.getContext('2d');
  222. // Calculate the aspect ratio of the image
  223. const aspectRatio = img.width / img.height;
  224. // Calculate the new width and height to fit within 100x100
  225. let newWidth, newHeight;
  226. if (aspectRatio > 1) {
  227. newWidth = 250 * aspectRatio;
  228. newHeight = 250;
  229. } else {
  230. newWidth = 250;
  231. newHeight = 250 / aspectRatio;
  232. }
  233. // Set the canvas size
  234. canvas.width = 250;
  235. canvas.height = 250;
  236. // Calculate the position to center the image
  237. const offsetX = (250 - newWidth) / 2;
  238. const offsetY = (250 - newHeight) / 2;
  239. // Draw the image on the canvas
  240. ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
  241. // Get the base64 representation of the compressed image
  242. const compressedSrc = canvas.toDataURL('image/jpeg');
  243. // Display the compressed image
  244. info.meta.profile_image_url = compressedSrc;
  245. inputFiles = null;
  246. };
  247. };
  248. if (
  249. inputFiles &&
  250. inputFiles.length > 0 &&
  251. ['image/gif', 'image/webp', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type'])
  252. ) {
  253. reader.readAsDataURL(inputFiles[0]);
  254. } else {
  255. console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`);
  256. inputFiles = null;
  257. }
  258. }}
  259. />
  260. <button
  261. class="flex space-x-1"
  262. on:click={() => {
  263. goto('/workspace/models');
  264. }}
  265. >
  266. <div class=" self-center">
  267. <svg
  268. xmlns="http://www.w3.org/2000/svg"
  269. viewBox="0 0 20 20"
  270. fill="currentColor"
  271. class="w-4 h-4"
  272. >
  273. <path
  274. fill-rule="evenodd"
  275. d="M17 10a.75.75 0 01-.75.75H5.612l4.158 3.96a.75.75 0 11-1.04 1.08l-5.5-5.25a.75.75 0 010-1.08l5.5-5.25a.75.75 0 111.04 1.08L5.612 9.25H16.25A.75.75 0 0117 10z"
  276. clip-rule="evenodd"
  277. />
  278. </svg>
  279. </div>
  280. <div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
  281. </button>
  282. <!-- <hr class="my-3 dark:border-gray-850" /> -->
  283. <form
  284. class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
  285. on:submit|preventDefault={() => {
  286. submitHandler();
  287. }}
  288. >
  289. <div class="flex justify-center my-4">
  290. <div class="self-center">
  291. <button
  292. class=" {info.meta.profile_image_url
  293. ? ''
  294. : 'p-4'} rounded-full dark:bg-gray-700 border border-dashed border-gray-200 flex items-center"
  295. type="button"
  296. on:click={() => {
  297. filesInputElement.click();
  298. }}
  299. >
  300. {#if info.meta.profile_image_url}
  301. <img
  302. src={info.meta.profile_image_url}
  303. alt="modelfile profile"
  304. class=" rounded-full size-16 object-cover"
  305. />
  306. {:else}
  307. <svg
  308. xmlns="http://www.w3.org/2000/svg"
  309. viewBox="0 0 24 24"
  310. fill="currentColor"
  311. class="size-8"
  312. >
  313. <path
  314. fill-rule="evenodd"
  315. d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
  316. clip-rule="evenodd"
  317. />
  318. </svg>
  319. {/if}
  320. </button>
  321. </div>
  322. </div>
  323. <div class="my-2 flex space-x-2">
  324. <div class="flex-1">
  325. <div class=" text-sm font-semibold mb-2">{$i18n.t('Name')}*</div>
  326. <div>
  327. <input
  328. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
  329. placeholder={$i18n.t('Name your model')}
  330. bind:value={name}
  331. required
  332. />
  333. </div>
  334. </div>
  335. <div class="flex-1">
  336. <div class=" text-sm font-semibold mb-2">{$i18n.t('Model ID')}*</div>
  337. <div>
  338. <input
  339. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
  340. placeholder={$i18n.t('Add a model id')}
  341. bind:value={id}
  342. required
  343. />
  344. </div>
  345. </div>
  346. </div>
  347. <div class="my-2">
  348. <div class=" text-sm font-semibold mb-2">{$i18n.t('Base Model (From)')}</div>
  349. <div>
  350. <select
  351. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
  352. placeholder="Select a base model (e.g. llama3, gpt-4o)"
  353. bind:value={info.base_model_id}
  354. on:change={(e) => {
  355. addUsage(e.target.value);
  356. }}
  357. required
  358. >
  359. <option value={null} class=" text-gray-900">{$i18n.t('Select a base model')}</option>
  360. {#each $models.filter((m) => !m?.preset) as model}
  361. <option value={model.id} class=" text-gray-900">{model.name}</option>
  362. {/each}
  363. </select>
  364. </div>
  365. </div>
  366. <div class="my-1">
  367. <div class="flex w-full justify-between items-center mb-1">
  368. <div class=" self-center text-sm font-semibold">{$i18n.t('Description')}</div>
  369. <button
  370. class="p-1 text-xs flex rounded transition"
  371. type="button"
  372. on:click={() => {
  373. if (info.meta.description === null) {
  374. info.meta.description = '';
  375. } else {
  376. info.meta.description = null;
  377. }
  378. }}
  379. >
  380. {#if info.meta.description === null}
  381. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  382. {:else}
  383. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  384. {/if}
  385. </button>
  386. </div>
  387. {#if info.meta.description !== null}
  388. <textarea
  389. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
  390. placeholder={$i18n.t('Add a short description about what this model does')}
  391. bind:value={info.meta.description}
  392. row="3"
  393. />
  394. {/if}
  395. </div>
  396. <hr class=" dark:border-gray-850 my-1" />
  397. <div class="my-2">
  398. <div class="flex w-full justify-between">
  399. <div class=" self-center text-sm font-semibold">{$i18n.t('Model Params')}</div>
  400. </div>
  401. <div class="mt-2">
  402. <div class="my-1">
  403. <div class=" text-xs font-semibold mb-2">{$i18n.t('System Prompt')}</div>
  404. <div>
  405. <textarea
  406. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg -mb-1"
  407. placeholder={`Write your model system prompt content here\ne.g.) You are Mario from Super Mario Bros, acting as an assistant.`}
  408. rows="4"
  409. bind:value={info.params.system}
  410. />
  411. </div>
  412. </div>
  413. <div class="flex w-full justify-between">
  414. <div class=" self-center text-xs font-semibold">
  415. {$i18n.t('Advanced Params')}
  416. </div>
  417. <button
  418. class="p-1 px-3 text-xs flex rounded transition"
  419. type="button"
  420. on:click={() => {
  421. showAdvanced = !showAdvanced;
  422. }}
  423. >
  424. {#if showAdvanced}
  425. <span class="ml-2 self-center">{$i18n.t('Hide')}</span>
  426. {:else}
  427. <span class="ml-2 self-center">{$i18n.t('Show')}</span>
  428. {/if}
  429. </button>
  430. </div>
  431. {#if showAdvanced}
  432. <div class="my-2">
  433. <AdvancedParams
  434. admin={true}
  435. bind:params
  436. on:change={(e) => {
  437. info.params = { ...info.params, ...params };
  438. }}
  439. />
  440. </div>
  441. {/if}
  442. </div>
  443. </div>
  444. <hr class=" dark:border-gray-850 my-1" />
  445. <div class="my-1">
  446. <div class="flex w-full justify-between items-center">
  447. <div class="flex w-full justify-between items-center">
  448. <div class=" self-center text-sm font-semibold">{$i18n.t('Prompt suggestions')}</div>
  449. <button
  450. class="p-1 text-xs flex rounded transition"
  451. type="button"
  452. on:click={() => {
  453. if (info.meta.suggestion_prompts === null) {
  454. info.meta.suggestion_prompts = [{ content: '' }];
  455. } else {
  456. info.meta.suggestion_prompts = null;
  457. }
  458. }}
  459. >
  460. {#if info.meta.suggestion_prompts === null}
  461. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  462. {:else}
  463. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  464. {/if}
  465. </button>
  466. </div>
  467. {#if info.meta.suggestion_prompts !== null}
  468. <button
  469. class="p-1 px-2 text-xs flex rounded transition"
  470. type="button"
  471. on:click={() => {
  472. if (
  473. info.meta.suggestion_prompts.length === 0 ||
  474. info.meta.suggestion_prompts.at(-1).content !== ''
  475. ) {
  476. info.meta.suggestion_prompts = [...info.meta.suggestion_prompts, { content: '' }];
  477. }
  478. }}
  479. >
  480. <svg
  481. xmlns="http://www.w3.org/2000/svg"
  482. viewBox="0 0 20 20"
  483. fill="currentColor"
  484. class="w-4 h-4"
  485. >
  486. <path
  487. d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
  488. />
  489. </svg>
  490. </button>
  491. {/if}
  492. </div>
  493. {#if info.meta.suggestion_prompts}
  494. <div class="flex flex-col space-y-1 mt-2">
  495. {#if info.meta.suggestion_prompts.length > 0}
  496. {#each info.meta.suggestion_prompts as prompt, promptIdx}
  497. <div class=" flex border dark:border-gray-600 rounded-lg">
  498. <input
  499. class="px-3 py-1.5 text-sm w-full bg-transparent outline-none border-r dark:border-gray-600"
  500. placeholder={$i18n.t('Write a prompt suggestion (e.g. Who are you?)')}
  501. bind:value={prompt.content}
  502. />
  503. <button
  504. class="px-2"
  505. type="button"
  506. on:click={() => {
  507. info.meta.suggestion_prompts.splice(promptIdx, 1);
  508. info.meta.suggestion_prompts = info.meta.suggestion_prompts;
  509. }}
  510. >
  511. <svg
  512. xmlns="http://www.w3.org/2000/svg"
  513. viewBox="0 0 20 20"
  514. fill="currentColor"
  515. class="w-4 h-4"
  516. >
  517. <path
  518. d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
  519. />
  520. </svg>
  521. </button>
  522. </div>
  523. {/each}
  524. {:else}
  525. <div class="text-xs text-center">No suggestion prompts</div>
  526. {/if}
  527. </div>
  528. {/if}
  529. </div>
  530. <div class="my-2">
  531. <Knowledge bind:knowledge />
  532. </div>
  533. <div class="my-2">
  534. <ToolsSelector bind:selectedToolIds={toolIds} tools={$tools} />
  535. </div>
  536. <div class="my-2">
  537. <FiltersSelector
  538. bind:selectedFilterIds={filterIds}
  539. filters={$functions.filter((func) => func.type === 'filter')}
  540. />
  541. </div>
  542. <div class="my-1">
  543. <div class="flex w-full justify-between mb-1">
  544. <div class=" self-center text-sm font-semibold">{$i18n.t('Capabilities')}</div>
  545. </div>
  546. <div class="flex flex-col">
  547. {#each Object.keys(capabilities) as capability}
  548. <div class=" flex items-center gap-2">
  549. <Checkbox
  550. state={capabilities[capability] ? 'checked' : 'unchecked'}
  551. on:change={(e) => {
  552. capabilities[capability] = e.detail === 'checked';
  553. }}
  554. />
  555. <div class=" py-0.5 text-sm w-full capitalize">
  556. {$i18n.t(capability)}
  557. </div>
  558. </div>
  559. {/each}
  560. </div>
  561. </div>
  562. <div class="my-1">
  563. <div class="flex w-full justify-between items-center">
  564. <div class=" self-center text-sm font-semibold">{$i18n.t('Tags')}</div>
  565. </div>
  566. <div class="mt-2">
  567. <Tags
  568. tags={info?.meta?.tags ?? []}
  569. deleteTag={(tagName) => {
  570. info.meta.tags = info.meta.tags.filter((tag) => tag.name !== tagName);
  571. }}
  572. addTag={(tagName) => {
  573. console.log(tagName);
  574. if (!(info?.meta?.tags ?? null)) {
  575. info.meta.tags = [{ name: tagName }];
  576. } else {
  577. info.meta.tags = [...info.meta.tags, { name: tagName }];
  578. }
  579. }}
  580. />
  581. </div>
  582. </div>
  583. <div class="my-2 text-gray-300 dark:text-gray-700">
  584. <div class="flex w-full justify-between mb-2">
  585. <div class=" self-center text-sm font-semibold">{$i18n.t('JSON Preview')}</div>
  586. <button
  587. class="p-1 px-3 text-xs flex rounded transition"
  588. type="button"
  589. on:click={() => {
  590. showPreview = !showPreview;
  591. }}
  592. >
  593. {#if showPreview}
  594. <span class="ml-2 self-center">{$i18n.t('Hide')}</span>
  595. {:else}
  596. <span class="ml-2 self-center">{$i18n.t('Show')}</span>
  597. {/if}
  598. </button>
  599. </div>
  600. {#if showPreview}
  601. <div>
  602. <textarea
  603. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
  604. rows="10"
  605. value={JSON.stringify(info, null, 2)}
  606. disabled
  607. readonly
  608. />
  609. </div>
  610. {/if}
  611. </div>
  612. <div class="my-2 flex justify-end mb-20">
  613. <button
  614. class=" text-sm px-3 py-2 transition rounded-xl {loading
  615. ? ' cursor-not-allowed bg-gray-100 dark:bg-gray-800'
  616. : ' bg-gray-50 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-800'} flex"
  617. type="submit"
  618. disabled={loading}
  619. >
  620. <div class=" self-center font-medium">{$i18n.t('Save & Create')}</div>
  621. {#if loading}
  622. <div class="ml-1.5 self-center">
  623. <svg
  624. class=" w-4 h-4"
  625. viewBox="0 0 24 24"
  626. fill="currentColor"
  627. xmlns="http://www.w3.org/2000/svg"
  628. ><style>
  629. .spinner_ajPY {
  630. transform-origin: center;
  631. animation: spinner_AtaB 0.75s infinite linear;
  632. }
  633. @keyframes spinner_AtaB {
  634. 100% {
  635. transform: rotate(360deg);
  636. }
  637. }
  638. </style><path
  639. d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
  640. opacity=".25"
  641. /><path
  642. d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
  643. class="spinner_ajPY"
  644. /></svg
  645. >
  646. </div>
  647. {/if}
  648. </button>
  649. </div>
  650. </form>
  651. </div>