mirror of
https://github.com/open-webui/computer.git
synced 2026-12-03 10:17:44 -05:00
refac
This commit is contained in:
1 parent
aedafae389
commit
82d5167e99
6 files changed
+453
-109
No files matched your search
@@ -0,0 +1,113 @@
|
||||
<script lang="ts">
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { onMount } from 'svelte';
|
||||
import { getAdminConfig, updateConfig } from '$lib/apis/admin';
|
||||
import { t } from '$lib/i18n';
|
||||
import ToggleSwitch from '$lib/components/common/ToggleSwitch.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
|
||||
let loading = $state(true);
|
||||
let saving = $state(false);
|
||||
|
||||
let enabled = $state(false);
|
||||
let maxConcurrent = $state(3);
|
||||
let maxIterations = $state(30);
|
||||
let maxOutput = $state(30000);
|
||||
let systemPrompt = $state('');
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const config = await getAdminConfig();
|
||||
enabled = config['subagents.enabled'] === true || config['subagents.enabled'] === 'true';
|
||||
maxConcurrent = Number(config['subagents.max_concurrent']) || 3;
|
||||
maxIterations = Number(config['subagents.max_iterations']) || 30;
|
||||
maxOutput = Number(config['subagents.max_output']) || 30000;
|
||||
systemPrompt = (config['subagents.system_prompt'] as string) || '';
|
||||
} catch {
|
||||
toast.error($t('admin.failedToLoadConfig'));
|
||||
}
|
||||
loading = false;
|
||||
});
|
||||
|
||||
async function save() {
|
||||
saving = true;
|
||||
try {
|
||||
await updateConfig({
|
||||
'subagents.enabled': enabled,
|
||||
'subagents.max_concurrent': maxConcurrent,
|
||||
'subagents.max_iterations': maxIterations,
|
||||
'subagents.max_output': maxOutput,
|
||||
'subagents.system_prompt': systemPrompt
|
||||
});
|
||||
toast.success($t('settings.saved'));
|
||||
} catch {
|
||||
toast.error($t('admin.failedToSave'));
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col min-h-full">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$t('admin.subagents')}</h2>
|
||||
|
||||
{#if loading}
|
||||
<div class="flex justify-center py-8"><Spinner size={16} /></div>
|
||||
{:else}
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.subagentsEnabled')}</span>
|
||||
<ToggleSwitch value={enabled} onchange={(v) => { enabled = v; }} />
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{$t('admin.subagentsHint')}
|
||||
</p>
|
||||
|
||||
{#if enabled}
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="sa-concurrent">{$t('admin.subagentsMaxConcurrent')}</label>
|
||||
<div class="flex items-center gap-1.5 mt-1">
|
||||
<input id="sa-concurrent" type="number" bind:value={maxConcurrent} min="1" max="10"
|
||||
class="w-16 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors" />
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600">{$t('admin.subagentsMaxConcurrentHint')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="sa-iterations">{$t('admin.subagentsMaxIterations')}</label>
|
||||
<div class="flex items-center gap-1.5 mt-1">
|
||||
<input id="sa-iterations" type="number" bind:value={maxIterations} min="1" max="100"
|
||||
class="w-16 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors" />
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600">{$t('admin.subagentsMaxIterationsHint')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="sa-output">{$t('admin.subagentsMaxOutput')}</label>
|
||||
<div class="flex items-center gap-1.5 mt-1">
|
||||
<input id="sa-output" type="number" bind:value={maxOutput} min="1000" max="100000" step="1000"
|
||||
class="w-20 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors" />
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600">chars</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="sa-prompt">{$t('admin.subagentsSystemPrompt')}</label>
|
||||
<textarea id="sa-prompt" bind:value={systemPrompt} rows="4"
|
||||
placeholder={$t('admin.subagentsSystemPromptPlaceholder')}
|
||||
class="w-full mt-1 px-2 py-1.5 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors resize-y font-mono" />
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-0.5">{$t('admin.subagentsSystemPromptHint')}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Save -->
|
||||
<div class="mt-auto pt-6 flex justify-end">
|
||||
<button
|
||||
class="text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100 disabled:opacity-50"
|
||||
onclick={() => save()}
|
||||
disabled={saving}
|
||||
>{$t('settings.save')}</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -13,6 +13,7 @@
|
||||
import AudioSettings from './Admin/AudioSettings.svelte';
|
||||
import AdminWeb from './Admin/Web.svelte';
|
||||
import ToolServers from './Admin/ToolServers.svelte';
|
||||
import Subagents from './Admin/Subagents.svelte';
|
||||
import { session } from '$lib/session';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
@@ -28,7 +29,8 @@
|
||||
| 'gateway'
|
||||
| 'audio'
|
||||
| 'web'
|
||||
| 'toolservers';
|
||||
| 'toolservers'
|
||||
| 'subagents';
|
||||
|
||||
interface Props {
|
||||
onclose: () => void;
|
||||
@@ -56,7 +58,8 @@
|
||||
{ id: 'gateway', label: $t('admin.gateway.tab'), icon: 'gateway' },
|
||||
{ id: 'audio', label: $t('admin.audio.title'), icon: 'microphone' },
|
||||
{ id: 'web', label: $t('admin.web'), icon: 'globe' },
|
||||
{ id: 'toolservers', label: $t('admin.toolServers'), icon: 'plug' }
|
||||
{ id: 'toolservers', label: $t('admin.toolServers'), icon: 'plug' },
|
||||
{ id: 'subagents', label: $t('admin.subagents'), icon: 'user' }
|
||||
]);
|
||||
</script>
|
||||
|
||||
@@ -137,6 +140,8 @@
|
||||
<AdminWeb />
|
||||
{:else if activeTab === 'toolservers'}
|
||||
<ToolServers />
|
||||
{:else if activeTab === 'subagents'}
|
||||
<Subagents />
|
||||
{/if}
|
||||
</div>
|
||||
</Modal>
|
||||
@@ -178,6 +178,10 @@
|
||||
return _t('chat.tool.fetchUrlFallback');
|
||||
}
|
||||
}
|
||||
case 'delegate_task': {
|
||||
const t = args.task || '?';
|
||||
return `Sub-agent: "${t.length > 60 ? t.slice(0, 60) + '…' : t}"`;
|
||||
}
|
||||
default: {
|
||||
// External tool: {server_id}_{tool_name} → "tool_name (server_id)"
|
||||
const idx = name.indexOf('_');
|
||||
|
||||
@@ -680,6 +680,18 @@
|
||||
"toolServers.updated": "Tool server updated",
|
||||
"toolServers.deleted": "Tool server deleted",
|
||||
"toolServers.saveFailed": "Failed to save tool server",
|
||||
"toolServers.deleteFailed": "Failed to delete tool server"
|
||||
"toolServers.deleteFailed": "Failed to delete tool server",
|
||||
|
||||
"admin.subagents": "Sub-agents",
|
||||
"admin.subagentsEnabled": "Enable sub-agents",
|
||||
"admin.subagentsHint": "Allow the AI to delegate tasks to sub-agents. Each sub-agent creates a real chat with full tool access. Uses additional LLM calls.",
|
||||
"admin.subagentsMaxConcurrent": "Max concurrent",
|
||||
"admin.subagentsMaxConcurrentHint": "simultaneous sub-agents",
|
||||
"admin.subagentsMaxIterations": "Max iterations",
|
||||
"admin.subagentsMaxIterationsHint": "tool loops per sub-agent",
|
||||
"admin.subagentsMaxOutput": "Max output",
|
||||
"admin.subagentsSystemPrompt": "System prompt",
|
||||
"admin.subagentsSystemPromptPlaceholder": "You are a sub-agent...",
|
||||
"admin.subagentsSystemPromptHint": "Leave empty for the built-in default."
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user