{#if loaded} {#if onBack}
{ onBack(); }} >
{$i18n.t('Back')}
{/if}
{ let reader = new FileReader(); reader.onload = (event) => { let originalImageUrl = `${event.target.result}`; 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(); // 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]['type'] ) ) { reader.readAsDataURL(inputFiles[0]); } else { console.log(`Unsupported File Type '${inputFiles[0]['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')}
{#if titleTranslations[langCode]}
(showTitleModal = true)}>
{/if}
{#if preset}
{$i18n.t('Base Model (From)')}
{ addUsage(e.target.value); }} required >
{$i18n.t('Select a base model')}
{#each $models.filter((m) => (model ? m.id !== model.id : true) && !m?.preset && m?.owned_by !== 'arena') 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')}
{#if showTitleModal}
{$i18n.t('Edit Title Translations')}
(showTitleModal = false)}>
{#each LANGS as lang}
{lang.toUpperCase()}
{/each}
(showTitleModal = false)} > Save
{/if} {#if preset}
{$i18n.t('Base Model (From)')}
{ addUsage(e.target.value); }} required >
{$i18n.t('Select a base model')}
{#each $models.filter((m) => (model ? m.id !== model.id : true) && !m?.preset && m?.owned_by !== 'arena') 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('Prompt suggestions')}
{ if ((info?.meta?.suggestion_prompts ?? null) === null) { info.meta.suggestion_prompts = []; } 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 ?? null) !== null}
{ editingIndex = null; newPrompt = createEmptyTranslations(); // Changed: use dynamic function showPromptModal = true; }} >
{/if}
{#if info?.meta?.suggestion_prompts}
{#if info.meta.suggestion_prompts.length > 0} {#each info.meta.suggestion_prompts as prompt, promptIdx}
{ editingIndex = promptIdx; newPrompt = parseContentToObj(prompt.content); // Changed: use parseContentToObj showPromptModal = true; }} title="Edit" >
{ info.meta.suggestion_prompts.splice(promptIdx, 1); info.meta.suggestion_prompts = [...info.meta.suggestion_prompts]; }} >
{/each} {:else}
No suggestion prompts
{/if}
{/if}
{#if showPromptModal}
{editingIndex === null ? $i18n.t('Add Translations') : $i18n.t('Edit Translations')}
{ showPromptModal = false; editingIndex = null; newPrompt = createEmptyTranslations(); // Changed: use dynamic function }} >
{#each LANGS as lang}
{lang.toUpperCase()}
(newPrompt[lang] = e.target.value)} placeholder={`Enter ${lang.toUpperCase()} translation`} />
{/each}
{ const firstLang = LANGS[0] || 'de'; if (newPrompt[firstLang]?.trim()) { if (editingIndex === null) { info.meta.suggestion_prompts = [ ...(info.meta.suggestion_prompts ?? []), { content: { ...newPrompt } } ]; } else { info.meta.suggestion_prompts[editingIndex].content = { ...newPrompt }; info.meta.suggestion_prompts = [...info.meta.suggestion_prompts]; } showPromptModal = false; newPrompt = createEmptyTranslations(); // Changed: use dynamic function editingIndex = null; } else { alert(`${firstLang.toUpperCase()} translation is required.`); // Changed: dynamic language } }}>{editingIndex === null ? 'Add' : 'Save'}
{/if}
func.type === 'filter')} />
func.type === 'action')} />
{$i18n.t('JSON Preview')}
{ showPreview = !showPreview; }} > {#if showPreview}
{$i18n.t('Hide')}
{:else}
{$i18n.t('Show')}
{/if}
{#if showPreview}
{/if}
{#if edit} {$i18n.t('Save & Update')} {:else} {$i18n.t('Save & Create')} {/if}
{#if loading}
{/if}
{/if}
{/if}