refac: direct external tools now require explicit toggle from input
This commit is contained in:
@@ -89,6 +89,7 @@
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import Sidebar from '../icons/Sidebar.svelte';
|
||||
import { getFunctions } from '$lib/apis/functions';
|
||||
import Image from '../common/Image.svelte';
|
||||
|
||||
export let chatIdProp = '';
|
||||
|
||||
@@ -1787,6 +1788,23 @@
|
||||
}))
|
||||
.filter((message) => message?.role === 'user' || message?.content?.trim());
|
||||
|
||||
const toolIds = [];
|
||||
const toolServerIds = [];
|
||||
|
||||
for (const toolId of selectedToolIds) {
|
||||
if (toolId.startsWith('direct_server:')) {
|
||||
let serverId = toolId.replace('direct_server:', '');
|
||||
// Check if serverId is a number
|
||||
if (!isNaN(parseInt(serverId))) {
|
||||
toolServerIds.push(parseInt(serverId));
|
||||
} else {
|
||||
toolServerIds.push(serverId);
|
||||
}
|
||||
} else {
|
||||
toolIds.push(toolId);
|
||||
}
|
||||
}
|
||||
|
||||
const res = await generateOpenAIChatCompletion(
|
||||
localStorage.token,
|
||||
{
|
||||
@@ -1807,8 +1825,10 @@
|
||||
files: (files?.length ?? 0) > 0 ? files : undefined,
|
||||
|
||||
filter_ids: selectedFilterIds.length > 0 ? selectedFilterIds : undefined,
|
||||
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
|
||||
tool_servers: $toolServers,
|
||||
tool_ids: toolIds.length > 0 ? toolIds : undefined,
|
||||
tool_servers: ($toolServers ?? []).filter(
|
||||
(server, idx) => toolServerIds.includes(idx) || toolServerIds.includes(server?.id)
|
||||
),
|
||||
features: getFeatures(),
|
||||
variables: {
|
||||
...getPromptVariables($user?.name, $settings?.userLocation ? userLocation : undefined)
|
||||
|
||||
Reference in New Issue
Block a user