refac: user valves
This commit is contained in:
@@ -78,6 +78,8 @@
|
||||
|
||||
import { getSuggestionRenderer } from '../common/RichTextInput/suggestions';
|
||||
import CommandSuggestionList from './MessageInput/CommandSuggestionList.svelte';
|
||||
import Knobs from '../icons/Knobs.svelte';
|
||||
import ValvesModal from '../workspace/common/ValvesModal.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@@ -112,6 +114,10 @@
|
||||
let inputVariables = {};
|
||||
let inputVariableValues = {};
|
||||
|
||||
let showValvesModal = false;
|
||||
let selectedValvesType = 'tool'; // 'tool' or 'function'
|
||||
let selectedValvesItemId = null;
|
||||
|
||||
$: onChange({
|
||||
prompt,
|
||||
files: files
|
||||
@@ -932,6 +938,16 @@
|
||||
onSave={inputVariablesModalCallback}
|
||||
/>
|
||||
|
||||
<ValvesModal
|
||||
bind:show={showValvesModal}
|
||||
userValves={true}
|
||||
type={selectedValvesType}
|
||||
id={selectedValvesItemId ?? null}
|
||||
on:save={async () => {
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
|
||||
{#if loaded}
|
||||
<div class="w-full font-primary">
|
||||
<div class=" mx-auto inset-x-0 bg-transparent flex justify-center">
|
||||
@@ -1449,6 +1465,12 @@
|
||||
bind:webSearchEnabled
|
||||
bind:imageGenerationEnabled
|
||||
bind:codeInterpreterEnabled
|
||||
onShowValves={(e) => {
|
||||
const { type, id } = e;
|
||||
selectedValvesType = type;
|
||||
selectedValvesItemId = id;
|
||||
showValvesModal = true;
|
||||
}}
|
||||
onClose={async () => {
|
||||
await tick();
|
||||
|
||||
@@ -1465,6 +1487,24 @@
|
||||
</IntegrationsMenu>
|
||||
{/if}
|
||||
|
||||
{#if selectedModelIds.length === 1 && $models.find((m) => m.id === selectedModelIds[0])?.has_user_valves}
|
||||
<div class="ml-1 flex gap-1.5">
|
||||
<Tooltip content={$i18n.t('Valves')} placement="top">
|
||||
<button
|
||||
id="model-valves-button"
|
||||
class="bg-transparent hover:bg-gray-100 text-gray-700 dark:text-white dark:hover:bg-gray-800 rounded-full size-8 flex justify-center items-center outline-hidden focus:outline-hidden"
|
||||
on:click={() => {
|
||||
selectedValvesType = 'function';
|
||||
selectedValvesItemId = selectedModelIds[0]?.split('.')[0];
|
||||
showValvesModal = true;
|
||||
}}
|
||||
>
|
||||
<Knobs className="size-4" strokeWidth="1.5" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="ml-1 flex gap-1.5">
|
||||
{#if (selectedToolIds ?? []).length > 0}
|
||||
<Tooltip
|
||||
|
||||
Reference in New Issue
Block a user