{#if loaded} {#if onBack}
{ onBack(); }} >
{'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 = '/static/favicon.png'; }} type="button" > Reset Image
{#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')}
{ if (info.meta.description === null) { info.meta.description = ''; } else { info.meta.description = null; } }} > {#if info.meta.description === null}
{$i18n.t('Default')}
{:else}
{$i18n.t('Custom')}
{/if}
{#if info.meta.description !== null}
{/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}
{ info.params = { ...info.params, ...params }; }} />
{/if}
{$i18n.t('Prompt suggestions')}
{ if ((info?.meta?.suggestion_prompts ?? null) === null) { info.meta.suggestion_prompts = [{ content: '' }]; } 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}
{ if ( info.meta.suggestion_prompts.length === 0 || info.meta.suggestion_prompts.at(-1).content !== '' ) { info.meta.suggestion_prompts = [ ...info.meta.suggestion_prompts, { content: '' } ]; } }} >
{/if}
{#if info?.meta?.suggestion_prompts}
{#if info.meta.suggestion_prompts.length > 0} {#each info.meta.suggestion_prompts as prompt, promptIdx}
{ info.meta.suggestion_prompts.splice(promptIdx, 1); info.meta.suggestion_prompts = info.meta.suggestion_prompts; }} >
{/each} {:else}
No suggestion prompts
{/if}
{/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}