open-webui/src/lib/components/chat/Controls/Controls.svelte

87 lines
2.5 KiB
Svelte
Raw Normal View History

2024-08-23 14:42:36 +00:00
<script lang="ts">
2024-07-09 02:26:31 +00:00
import { createEventDispatcher, getContext } from 'svelte';
2024-07-08 23:55:12 +00:00
const dispatch = createEventDispatcher();
2024-07-09 02:26:31 +00:00
const i18n = getContext('i18n');
2024-07-08 23:55:12 +00:00
import XMark from '$lib/components/icons/XMark.svelte';
2024-07-09 02:26:31 +00:00
import AdvancedParams from '../Settings/Advanced/AdvancedParams.svelte';
2024-08-02 15:19:52 +00:00
import Valves from '$lib/components/chat/Controls/Valves.svelte';
2024-07-17 09:39:37 +00:00
import FileItem from '$lib/components/common/FileItem.svelte';
2024-07-28 22:17:49 +00:00
import Collapsible from '$lib/components/common/Collapsible.svelte';
2024-07-09 02:26:31 +00:00
import { user } from '$lib/stores';
2024-07-12 00:18:18 +00:00
export let models = [];
2024-07-17 09:39:37 +00:00
export let chatFiles = [];
2024-07-09 02:26:31 +00:00
export let params = {};
2024-07-08 23:55:12 +00:00
</script>
<div class=" dark:text-white">
2024-07-09 02:26:31 +00:00
<div class=" flex justify-between dark:text-gray-100 mb-2">
<div class=" text-lg font-medium self-center font-primary">{$i18n.t('Chat Controls')}</div>
<button
class="self-center"
on:click={() => {
dispatch('close');
}}
>
<XMark className="size-4" />
</button>
</div>
2024-07-08 23:55:12 +00:00
2024-07-28 22:17:49 +00:00
<div class=" dark:text-gray-200 text-sm font-primary py-0.5">
2024-07-17 09:39:37 +00:00
{#if chatFiles.length > 0}
2024-07-28 22:17:49 +00:00
<Collapsible title={$i18n.t('Files')} open={true}>
<div class="flex flex-col gap-1 mt-1.5" slot="content">
2024-07-17 17:04:18 +00:00
{#each chatFiles as file, fileIdx}
2024-07-17 09:39:37 +00:00
<FileItem
className="w-full"
url={`${file?.url}`}
name={file.name}
type={file.type}
size={file?.size}
2024-07-17 09:39:37 +00:00
dismissible={true}
on:dismiss={() => {
// Remove the file from the chatFiles array
2024-07-17 17:04:18 +00:00
chatFiles.splice(fileIdx, 1);
chatFiles = chatFiles;
2024-07-17 09:39:37 +00:00
}}
/>
{/each}
</div>
2024-07-28 22:17:49 +00:00
</Collapsible>
2024-07-17 09:39:37 +00:00
<hr class="my-2 border-gray-100 dark:border-gray-800" />
{/if}
2024-08-02 15:19:52 +00:00
<Collapsible title={$i18n.t('Valves')}>
<div class="text-sm mt-1.5" slot="content">
<Valves />
2024-07-12 00:18:18 +00:00
</div>
2024-08-02 15:19:52 +00:00
</Collapsible>
2024-07-12 00:18:18 +00:00
2024-08-02 15:19:52 +00:00
<hr class="my-2 border-gray-100 dark:border-gray-800" />
2024-07-12 00:18:18 +00:00
2024-07-28 22:17:49 +00:00
<Collapsible title={$i18n.t('System Prompt')} open={true}>
<div class=" mt-1.5" slot="content">
2024-07-09 02:26:31 +00:00
<textarea
bind:value={params.system}
2024-07-28 22:17:49 +00:00
class="w-full rounded-lg px-3.5 py-2.5 text-sm dark:text-gray-300 dark:bg-gray-850 border border-gray-100 dark:border-gray-800 outline-none resize-none"
rows="4"
2024-07-13 13:22:16 +00:00
placeholder={$i18n.t('Enter system prompt')}
2024-07-09 02:26:31 +00:00
/>
</div>
2024-07-28 22:17:49 +00:00
</Collapsible>
2024-07-08 23:55:12 +00:00
2024-07-09 03:17:09 +00:00
<hr class="my-2 border-gray-100 dark:border-gray-800" />
2024-07-09 02:26:31 +00:00
2024-07-28 22:17:49 +00:00
<Collapsible title={$i18n.t('Advanced Params')} open={true}>
<div class="text-sm mt-1.5" slot="content">
<div>
<AdvancedParams admin={$user?.role === 'admin'} bind:params />
2024-07-28 22:17:49 +00:00
</div>
2024-07-09 02:26:31 +00:00
</div>
2024-07-28 22:17:49 +00:00
</Collapsible>
2024-07-09 02:26:31 +00:00
</div>
2024-07-08 23:55:12 +00:00
</div>