refac
This commit is contained in:
@@ -2618,7 +2618,10 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
|
||||
# Resolve terminal tools if terminal_id is set (outside tool_ids check
|
||||
# so system terminals work even when no other tools are selected)
|
||||
if terminal_id:
|
||||
terminal_capability = (model.get('info', {}).get('meta', {}).get('capabilities') or {}).get(
|
||||
'terminal', True
|
||||
)
|
||||
if terminal_id and terminal_capability:
|
||||
try:
|
||||
terminal_result = await get_terminal_tools(
|
||||
request,
|
||||
|
||||
@@ -2306,6 +2306,9 @@
|
||||
// Use the user-selected terminal from the dropdown
|
||||
const activeTerminalId = $selectedTerminalId ?? null;
|
||||
|
||||
// Only send terminal_id if the model has terminal capability enabled
|
||||
const terminalEnabled = model.info?.meta?.capabilities?.terminal ?? true;
|
||||
|
||||
const res = await generateOpenAIChatCompletion(
|
||||
localStorage.token,
|
||||
{
|
||||
@@ -2323,7 +2326,7 @@
|
||||
filter_ids: selectedFilterIds.length > 0 ? selectedFilterIds : undefined,
|
||||
tool_ids: toolIds.length > 0 ? toolIds : undefined,
|
||||
skill_ids: skillIds.length > 0 ? skillIds : undefined,
|
||||
terminal_id: activeTerminalId ?? undefined,
|
||||
terminal_id: terminalEnabled ? (activeTerminalId ?? undefined) : undefined,
|
||||
tool_servers: [
|
||||
...($toolServers ?? []).filter(
|
||||
(server, idx) => toolServerIds.includes(idx) || toolServerIds.includes(server?.id)
|
||||
|
||||
@@ -495,6 +495,14 @@
|
||||
$models.find((m) => m.id === model)?.info?.meta?.capabilities?.code_interpreter ?? true
|
||||
);
|
||||
|
||||
let terminalCapableModels = [];
|
||||
$: terminalCapableModels = (
|
||||
atSelectedModel?.id ? [atSelectedModel.id] : selectedModels
|
||||
).filter(
|
||||
(model) =>
|
||||
$models.find((m) => m.id === model)?.info?.meta?.capabilities?.terminal ?? true
|
||||
);
|
||||
|
||||
let toggleFilters = [];
|
||||
$: toggleFilters = (atSelectedModel?.id ? [atSelectedModel.id] : selectedModels)
|
||||
.map((id) => ($models.find((model) => model.id === id) || {})?.filters ?? [])
|
||||
@@ -530,6 +538,11 @@
|
||||
codeInterpreterEnabled = false;
|
||||
}
|
||||
|
||||
// Clear selected terminal when model doesn't support terminal
|
||||
$: if ($selectedTerminalId && terminalCapableModels.length === 0) {
|
||||
selectedTerminalId.set(null);
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
const element = document.getElementById('messages-container');
|
||||
element.scrollTo({
|
||||
@@ -1908,7 +1921,7 @@
|
||||
|
||||
{#if !history?.currentId || history.messages[history.currentId]?.done == true}
|
||||
<!-- Terminal Server Selector -->
|
||||
{#if ($terminalServers ?? []).length > 0 || ($settings?.terminalServers ?? []).some((s) => s.url)}
|
||||
{#if terminalCapableModels.length > 0 && (($terminalServers ?? []).length > 0 || ($settings?.terminalServers ?? []).some((s) => s.url))}
|
||||
<TerminalMenu bind:show={showTerminalMenu} />
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
label: $i18n.t('Code Interpreter'),
|
||||
description: $i18n.t('Model can execute code and perform calculations')
|
||||
},
|
||||
terminal: {
|
||||
label: $i18n.t('Terminal'),
|
||||
description: $i18n.t(
|
||||
'Model can access Open Terminal for command execution and file management'
|
||||
)
|
||||
},
|
||||
usage: {
|
||||
label: $i18n.t('Usage'),
|
||||
description: $i18n.t(
|
||||
@@ -60,6 +66,7 @@
|
||||
web_search?: boolean;
|
||||
image_generation?: boolean;
|
||||
code_interpreter?: boolean;
|
||||
terminal?: boolean;
|
||||
usage?: boolean;
|
||||
citations?: boolean;
|
||||
status_updates?: boolean;
|
||||
|
||||
@@ -839,9 +839,11 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if capabilities.terminal}
|
||||
<div class="my-4">
|
||||
<TerminalSelector bind:terminalId />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="my-4">
|
||||
<div class="flex w-full justify-between mb-1">
|
||||
|
||||
@@ -104,6 +104,7 @@ export const DEFAULT_CAPABILITIES = {
|
||||
web_search: true,
|
||||
image_generation: true,
|
||||
code_interpreter: true,
|
||||
terminal: true,
|
||||
citations: true,
|
||||
status_updates: true,
|
||||
usage: undefined,
|
||||
|
||||
Reference in New Issue
Block a user