Browse Source

refac: model editor

Timothy Jaeryang Baek 3 months ago
parent
commit
6408452e8f
1 changed files with 14 additions and 9 deletions
  1. 14 9
      src/lib/components/workspace/Models/ModelEditor.svelte

+ 14 - 9
src/lib/components/workspace/Models/ModelEditor.svelte

@@ -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 ?? []}