refac: suggestion prompts

This commit is contained in:
Timothy J. Baek 2024-05-24 23:54:22 -07:00
parent bbf5e37f6f
commit 0c7f0f4430
2 changed files with 165 additions and 108 deletions

View File

@ -386,11 +386,32 @@
</div> </div>
<div class="my-2"> <div class="my-2">
<div class="flex w-full justify-between mb-2"> <div class="flex w-full justify-between items-center">
<div class="flex w-full justify-between items-center">
<div class=" self-center text-sm font-semibold">{$i18n.t('Prompt suggestions')}</div> <div class=" self-center text-sm font-semibold">{$i18n.t('Prompt suggestions')}</div>
<button <button
class="p-1 px-3 text-xs flex rounded transition" class="p-1 text-xs flex rounded transition"
type="button"
on:click={() => {
if (info.meta.suggestion_prompts === null) {
info.meta.suggestion_prompts = [{ content: '' }];
} else {
info.meta.suggestion_prompts = null;
}
}}
>
{#if info.meta.suggestion_prompts === null}
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
{:else}
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
{/if}
</button>
</div>
{#if info.meta.suggestion_prompts !== null}
<button
class="p-1 px-2 text-xs flex rounded transition"
type="button" type="button"
on:click={() => { on:click={() => {
if ( if (
@ -412,8 +433,12 @@
/> />
</svg> </svg>
</button> </button>
{/if}
</div> </div>
<div class="flex flex-col space-y-1">
{#if info.meta.suggestion_prompts}
<div class="flex flex-col space-y-1 mt-2">
{#if info.meta.suggestion_prompts.length > 0}
{#each info.meta.suggestion_prompts as prompt, promptIdx} {#each info.meta.suggestion_prompts as prompt, promptIdx}
<div class=" flex border dark:border-gray-600 rounded-lg"> <div class=" flex border dark:border-gray-600 rounded-lg">
<input <input
@ -443,7 +468,11 @@
</button> </button>
</div> </div>
{/each} {/each}
{:else}
<div class="text-xs text-center">No suggestion prompts</div>
{/if}
</div> </div>
{/if}
</div> </div>
<div class="my-2"> <div class="my-2">

View File

@ -44,8 +44,7 @@
meta: { meta: {
profile_image_url: '/favicon.png', profile_image_url: '/favicon.png',
description: '', description: '',
content: '', suggestion_prompts: null
suggestion_prompts: []
}, },
params: { params: {
system: '' system: ''
@ -366,11 +365,32 @@
</div> </div>
<div class="my-2"> <div class="my-2">
<div class="flex w-full justify-between mb-2"> <div class="flex w-full justify-between items-center">
<div class="flex w-full justify-between items-center">
<div class=" self-center text-sm font-semibold">{$i18n.t('Prompt suggestions')}</div> <div class=" self-center text-sm font-semibold">{$i18n.t('Prompt suggestions')}</div>
<button <button
class="p-1 px-3 text-xs flex rounded transition" class="p-1 text-xs flex rounded transition"
type="button"
on:click={() => {
if (info.meta.suggestion_prompts === null) {
info.meta.suggestion_prompts = [{ content: '' }];
} else {
info.meta.suggestion_prompts = null;
}
}}
>
{#if info.meta.suggestion_prompts === null}
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
{:else}
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
{/if}
</button>
</div>
{#if info.meta.suggestion_prompts !== null}
<button
class="p-1 px-2 text-xs flex rounded transition"
type="button" type="button"
on:click={() => { on:click={() => {
if ( if (
@ -392,8 +412,12 @@
/> />
</svg> </svg>
</button> </button>
{/if}
</div> </div>
<div class="flex flex-col space-y-1">
{#if info.meta.suggestion_prompts}
<div class="flex flex-col space-y-1 mt-2">
{#if info.meta.suggestion_prompts.length > 0}
{#each info.meta.suggestion_prompts as prompt, promptIdx} {#each info.meta.suggestion_prompts as prompt, promptIdx}
<div class=" flex border dark:border-gray-600 rounded-lg"> <div class=" flex border dark:border-gray-600 rounded-lg">
<input <input
@ -423,7 +447,11 @@
</button> </button>
</div> </div>
{/each} {/each}
{:else}
<div class="text-xs text-center">No suggestion prompts</div>
{/if}
</div> </div>
{/if}
</div> </div>
<div class="my-2"> <div class="my-2">