Commit 0c7f0f44 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

refac: suggestion prompts

parent bbf5e37f
...@@ -386,11 +386,32 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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">
......
...@@ -44,8 +44,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment