refac: model editor

This commit is contained in:
Timothy Jaeryang Baek 2025-01-20 23:44:47 -08:00
parent 94d0f84c0c
commit 6408452e8f

@ -45,6 +45,8 @@
let id = '';
let name = '';
let enableDescription = true;
$: if (!edit) {
if (name) {
id = name
@ -115,6 +117,12 @@
info.access_control = accessControl;
info.meta.capabilities = capabilities;
if (enableDescription) {
info.meta.description = info.meta.description.trim() === '' ? null : info.meta.description;
} else {
info.meta.description = null;
}
if (knowledge.length > 0) {
info.meta.knowledge = knowledge;
} else {
@ -178,6 +186,8 @@
id = model.id;
enableDescription = model?.meta?.description !== null;
if (model.base_model_id) {
const base_model = $models
.filter((m) => !m?.preset && !(m?.arena ?? false))
@ -479,14 +489,10 @@
class="p-1 text-xs flex rounded transition"
type="button"
on:click={() => {
if (info.meta.description === null) {
info.meta.description = '';
} else {
info.meta.description = null;
}
enableDescription = !enableDescription;
}}
>
{#if info.meta.description === null}
{#if !enableDescription}
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
{:else}
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
@ -494,17 +500,16 @@
</button>
</div>
{#if info.meta.description !== null}
{#if enableDescription}
<Textarea
className=" text-sm w-full bg-transparent outline-none resize-none overflow-y-hidden "
placeholder={$i18n.t('Add a short description about what this model does')}
rows={3}
bind:value={info.meta.description}
/>
{/if}
</div>
<div class="my-1">
<div class=" mt-2 my-1">
<div class="">
<Tags
tags={info?.meta?.tags ?? []}