mirror of
https://github.com/open-webui/computer.git
synced 2026-11-25 14:57:45 -05:00
refac
This commit is contained in:
1 parent
ef7ea5f828
commit
942eba00cf
3 files changed
+19
-7
No files matched your search
@@ -86,8 +86,7 @@
|
||||
id="sa-concurrent"
|
||||
type="number"
|
||||
bind:value={maxConcurrent}
|
||||
min="1"
|
||||
max="100"
|
||||
min="-1"
|
||||
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-[0.6875rem] text-gray-400 dark:text-gray-600"
|
||||
@@ -123,8 +122,7 @@
|
||||
id="sa-async"
|
||||
type="number"
|
||||
bind:value={maxAsync}
|
||||
min="1"
|
||||
max="100"
|
||||
min="-1"
|
||||
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-[0.6875rem] text-gray-400 dark:text-gray-600"
|
||||
|
||||
@@ -39,10 +39,12 @@ async def active_count() -> int:
|
||||
|
||||
async def reserve_async_subagent(max_async: int, **record: Any) -> dict[str, Any]:
|
||||
"""Reserve capacity for a background subagent before creating its chat."""
|
||||
max_async = max(1, int(max_async or 20))
|
||||
max_async = int(max_async or 20)
|
||||
if max_async != -1:
|
||||
max_async = max(1, max_async)
|
||||
async with _lock:
|
||||
running = sum(1 for r in _records.values() if r.get("status") in {"starting", "running"})
|
||||
if running >= max_async:
|
||||
if max_async != -1 and running >= max_async:
|
||||
return {
|
||||
"status": "rejected",
|
||||
"error": (
|
||||
|
||||
+13
-1
@@ -2318,8 +2318,20 @@ async def delegate_task(
|
||||
}
|
||||
)
|
||||
|
||||
if config["max_concurrent"] == -1:
|
||||
return await _run_subagent_chat(
|
||||
task=task,
|
||||
context=context,
|
||||
workspace=__context__["workspace"],
|
||||
connection=__context__["connection"],
|
||||
model=__context__["model_id"],
|
||||
user_id=__context__["user_id"],
|
||||
parent_chat_id=__context__["chat_id"],
|
||||
config=config,
|
||||
)
|
||||
|
||||
if _subagent_semaphore is None:
|
||||
_subagent_semaphore = asyncio.Semaphore(config["max_concurrent"])
|
||||
_subagent_semaphore = asyncio.Semaphore(max(1, config["max_concurrent"]))
|
||||
|
||||
async with _subagent_semaphore:
|
||||
return await _run_subagent_chat(
|
||||
|
||||
Reference in new issue
Block a user