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