{#if loaded} { if (edit && model?.id) { try { await updateModelAccessGrants(localStorage.token, model.id, accessGrants); toast.success($i18n.t('Saved')); } catch (error) { toast.error(`${error}`); } } }} /> {#if onBack} { onBack(); }} > {$i18n.t('Back')} {/if} { let reader = new FileReader(); reader.onload = (event) => { let originalImageUrl = `${event.target?.result}`; // For animated formats (gif, webp), skip resizing to preserve animation const fileType = (inputFiles[0] as any)?.['type']; if (fileType === 'image/gif' || fileType === 'image/webp') { info.meta.profile_image_url = originalImageUrl; inputFiles = null; filesInputElement.value = ''; return; } const img = new Image(); img.src = originalImageUrl; img.onload = function () { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); // Calculate the aspect ratio of the image const aspectRatio = img.width / img.height; // Calculate the new width and height to fit within 100x100 let newWidth, newHeight; if (aspectRatio > 1) { newWidth = 250 * aspectRatio; newHeight = 250; } else { newWidth = 250; newHeight = 250 / aspectRatio; } // Set the canvas size canvas.width = 250; canvas.height = 250; // Calculate the position to center the image const offsetX = (250 - newWidth) / 2; const offsetY = (250 - newHeight) / 2; // Draw the image on the canvas ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight); // Get the base64 representation of the compressed image const compressedSrc = canvas.toDataURL('image/webp', 0.8); // Display the compressed image info.meta.profile_image_url = compressedSrc; inputFiles = null; filesInputElement.value = ''; }; }; if ( inputFiles && inputFiles.length > 0 && ['image/gif', 'image/webp', 'image/jpeg', 'image/png', 'image/svg+xml'].includes( (inputFiles[0] as any)?.['type'] ) ) { reader.readAsDataURL(inputFiles[0]); } else { console.log(`Unsupported File Type '${(inputFiles[0] as any)?.['type']}'.`); inputFiles = null; } }} /> {#if !edit || (edit && model)} { submitHandler(); }} > { filesInputElement.click(); }} > {#if info.meta.profile_image_url} {:else} {/if} { info.meta.profile_image_url = `${WEBUI_BASE_URL}/static/favicon.png`; }} type="button" > {$i18n.t('Reset Image')} { showAccessControlModal = true; }} > {$i18n.t('Access')} {#if preset} {$i18n.t('Base Model (From)')} {$i18n.t('Select a base model')} {#each $models.filter((m) => (model ? m.id !== model.id : true) && !m?.preset && m?.owned_by !== 'arena' && !(m?.direct ?? false)) as model} {model.name} {/each} {/if} {$i18n.t('Description')} { enableDescription = !enableDescription; }} > {#if !enableDescription} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} {/if} {#if enableDescription} {/if} { const tagName = e.detail; info.meta.tags = info.meta.tags.filter((tag) => tag.name !== tagName); }} on:add={(e) => { const tagName = e.detail; if (!(info?.meta?.tags ?? null)) { info.meta.tags = [{ name: tagName }]; } else { info.meta.tags = [...info.meta.tags, { name: tagName }]; } }} /> {$i18n.t('Model Params')} {$i18n.t('System Prompt')} {$i18n.t('Advanced Params')} { showAdvanced = !showAdvanced; }} > {#if showAdvanced} {$i18n.t('Hide')} {:else} {$i18n.t('Show')} {/if} {#if showAdvanced} {/if} {$i18n.t('Prompts')} { if ((info?.meta?.suggestion_prompts ?? null) === null) { info.meta.suggestion_prompts = [{ content: '', title: ['', ''] }]; } else { info.meta.suggestion_prompts = null; } }} > {#if (info?.meta?.suggestion_prompts ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} {/if} {#if info?.meta?.suggestion_prompts} {/if} {#if ($functions ?? []).filter((func) => func.type === 'filter').length > 0 || ($functions ?? []).filter((func) => func.type === 'action').length > 0} {#if ($functions ?? []).filter((func) => func.type === 'filter').length > 0} func.type === 'filter')} /> {@const toggleableFilters = $functions.filter( (func) => func.type === 'filter' && (filterIds.includes(func.id) || func?.is_global) && func?.meta?.toggle )} {#if toggleableFilters.length > 0} {/if} {/if} {#if ($functions ?? []).filter((func) => func.type === 'action').length > 0} func.type === 'action')} /> {/if} {/if} {#if Object.keys(capabilities).filter((key) => capabilities[key]).length > 0} {@const availableFeatures = Object.entries(capabilities) .filter( ([key, value]) => value && ['web_search', 'code_interpreter', 'image_generation'].includes(key) ) .map(([key, value]) => key)} {#if availableFeatures.length > 0} {/if} {/if} {#if capabilities.builtin_tools} {/if} {$i18n.t('TTS Voice')} {#if edit} {$i18n.t('Save & Update')} {:else} {$i18n.t('Save & Create')} {/if} {#if loading} {/if} {$i18n.t('JSON Preview')} { showPreview = !showPreview; }} > {#if showPreview} {$i18n.t('Hide')} {:else} {$i18n.t('Show')} {/if} {#if showPreview} {/if} {/if} {/if}