This commit is contained in:
Timothy Jaeryang Baek
2024-11-16 17:49:13 -08:00
parent af0ba53715
commit a1ce8422fd
9 changed files with 67 additions and 69 deletions

View File

@@ -153,15 +153,17 @@
console.log('saveSessionSelectedModels', selectedModels, sessionStorage.selectedModels);
};
$: if (selectedModelIds) {
$: if (selectedModels) {
setToolIds();
}
const setToolIds = () => {
const setToolIds = async () => {
if (selectedModels.length !== 1) {
return;
}
console.log('setToolIds', selectedModels);
const model = $models.find((m) => m.id === selectedModels[0]);
if (model) {
selectedToolIds = model?.info?.meta?.toolIds ?? [];
@@ -495,8 +497,6 @@
}
}
console.log(selectedModels);
await showControls.set(false);
await showCallOverlay.set(false);
await showOverview.set(false);
@@ -2282,13 +2282,6 @@
bind:selectedToolIds
bind:webSearchEnabled
bind:atSelectedModel
availableToolIds={selectedModelIds.reduce((a, e, i, arr) => {
const model = $models.find((m) => m.id === e);
if (model?.info?.meta?.toolIds ?? false) {
return [...new Set([...a, ...model.info.meta.toolIds])];
}
return a;
}, [])}
transparentBackground={$settings?.backgroundImageUrl ?? false}
{stopResponse}
{createMessagePair}
@@ -2326,13 +2319,6 @@
bind:selectedToolIds
bind:webSearchEnabled
bind:atSelectedModel
availableToolIds={selectedModelIds.reduce((a, e, i, arr) => {
const model = $models.find((m) => m.id === e);
if (model?.info?.meta?.toolIds ?? false) {
return [...new Set([...a, ...model.info.meta.toolIds])];
}
return a;
}, [])}
transparentBackground={$settings?.backgroundImageUrl ?? false}
{stopResponse}
{createMessagePair}

View File

@@ -51,7 +51,7 @@
export let prompt = '';
export let files = [];
export let availableToolIds = [];
export let selectedToolIds = [];
export let webSearchEnabled = false;

View File

@@ -1,9 +1,10 @@
<script lang="ts">
import { DropdownMenu } from 'bits-ui';
import { flyAndScale } from '$lib/utils/transitions';
import { getContext, onMount } from 'svelte';
import { getContext, onMount, tick } from 'svelte';
import { config, user, tools as _tools } from '$lib/stores';
import { getTools } from '$lib/apis/tools';
import Dropdown from '$lib/components/common/Dropdown.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
@@ -11,17 +12,13 @@
import Switch from '$lib/components/common/Switch.svelte';
import GlobeAltSolid from '$lib/components/icons/GlobeAltSolid.svelte';
import WrenchSolid from '$lib/components/icons/WrenchSolid.svelte';
import { getTools } from '$lib/apis/tools';
const i18n = getContext('i18n');
export let uploadFilesHandler: Function;
export let availableToolIds: string[] = [];
export let selectedToolIds: string[] = [];
export let webSearchEnabled: boolean;
export let onClose: Function;
let tools = {};
@@ -31,12 +28,7 @@
init();
}
$: if (tools) {
selectedToolIds = Object.keys(tools).filter((toolId) => tools[toolId]?.enabled ?? false);
}
const init = async () => {
console.log('init');
if ($_tools === null) {
await _tools.set(await getTools(localStorage.token));
}
@@ -95,7 +87,17 @@
</div>
<div class=" flex-shrink-0">
<Switch state={tools[toolId].enabled} />
<Switch
state={tools[toolId].enabled}
on:change={async () => {
await tick();
if (tools[toolId].enabled) {
selectedToolIds = [...selectedToolIds, toolId];
} else {
selectedToolIds = selectedToolIds.filter((id) => id !== toolId);
}
}}
/>
</div>
</button>
{/each}

View File

@@ -32,7 +32,7 @@
export let prompt = '';
export let files = [];
export let availableToolIds = [];
export let selectedToolIds = [];
export let webSearchEnabled = false;
@@ -200,7 +200,6 @@
bind:selectedToolIds
bind:webSearchEnabled
bind:atSelectedModel
{availableToolIds}
{transparentBackground}
{stopResponse}
{createMessagePair}