mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-24 22:37:38 -05:00
refac
This commit is contained in:
1 parent
22500ecc24
commit
46ac49fe09
4 files changed
+11
-7
No files matched your search
@@ -1910,6 +1910,7 @@ async def view_chat(
|
||||
|
||||
async def delegate_task(
|
||||
task: str,
|
||||
title: str = '',
|
||||
context: str = '',
|
||||
file_ids: list[str] | None = None,
|
||||
background: bool = False,
|
||||
@@ -1924,6 +1925,7 @@ async def delegate_task(
|
||||
Delegate focused work to a parallel sub-agent using the current tools.
|
||||
|
||||
:param task: The specific task for the sub-agent to complete
|
||||
:param title: A short name for the task, 3 to 6 words
|
||||
:param context: Relevant context, decisions, or file paths for the task
|
||||
:param file_ids: Attached file IDs the sub-agent needs. Use this for images or files;
|
||||
do not put file IDs only in context.
|
||||
@@ -1942,6 +1944,7 @@ async def delegate_task(
|
||||
task,
|
||||
context,
|
||||
background,
|
||||
title=title,
|
||||
file_ids=file_ids,
|
||||
model_id=model_id,
|
||||
request=__request__,
|
||||
|
||||
@@ -491,6 +491,7 @@ async def delegate(
|
||||
context: str,
|
||||
background: bool,
|
||||
*,
|
||||
title: str = '',
|
||||
file_ids: list[str] | None = None,
|
||||
model_id: str | None = None,
|
||||
request: Request,
|
||||
@@ -504,6 +505,7 @@ async def delegate(
|
||||
task = task.strip()
|
||||
if not task:
|
||||
return 'Error: task must not be empty.'
|
||||
title = ' '.join((title or '').split() or task.split())[:60]
|
||||
if not parent_chat_id or not user_data.get('id'):
|
||||
return 'Error: chat and user context are required.'
|
||||
|
||||
@@ -645,7 +647,7 @@ async def delegate(
|
||||
ChatForm(
|
||||
chat={
|
||||
'id': chat_id,
|
||||
'title': f'Sub-agent: {task[:60]}',
|
||||
'title': title,
|
||||
'models': [model_id],
|
||||
'machine_id': machine_id_of(run),
|
||||
# Read when the user's answer or message continues this chat.
|
||||
@@ -836,6 +838,7 @@ async def delegate(
|
||||
'to use the result or continue without it.'
|
||||
),
|
||||
'',
|
||||
f'Title: {title}',
|
||||
f'Original task: {task}',
|
||||
]
|
||||
if context:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
const [head, ...result] = report.split('--- RESULT ---');
|
||||
const field = (pattern: RegExp) => head.match(pattern)?.[1]?.trim() ?? '';
|
||||
return {
|
||||
task: field(/^Original task: (.*)$/m),
|
||||
title: field(/^Title: (.*)\nOriginal task: /m) || field(/^Original task: (.*)$/m),
|
||||
chatId: field(/^Subagent chat: (.*)$/m),
|
||||
status: field(/^Status: (\S+)/m),
|
||||
duration: field(/Duration: (\S+)/),
|
||||
@@ -44,7 +44,7 @@
|
||||
aria-expanded={!!expanded[index]}
|
||||
on:click={() => (expanded[index] = !expanded[index])}
|
||||
>
|
||||
<span dir="auto" class="min-w-0 truncate">{label(report.status)} · {report.task}</span>
|
||||
<span dir="auto" class="min-w-0 truncate">{label(report.status)} · {report.title}</span>
|
||||
<span class="shrink-0 text-xs tabular-nums">{report.duration}</span>
|
||||
<ChevronDown
|
||||
strokeWidth="3.5"
|
||||
@@ -70,7 +70,7 @@
|
||||
type="button"
|
||||
class="mt-1 text-xs text-base-400 transition hover:text-base-600 dark:text-base-600 dark:hover:text-base-400"
|
||||
on:click={() =>
|
||||
appLayout?.openPageTab?.({ href: `/c/${report.chatId}`, label: report.task })}
|
||||
appLayout?.openPageTab?.({ href: `/c/${report.chatId}`, label: report.title })}
|
||||
>
|
||||
{$i18n.t('Open thread')}
|
||||
</button>
|
||||
|
||||
@@ -238,9 +238,7 @@ export function buildToolCallToken(
|
||||
typeof item.arguments === 'string'
|
||||
? JSON.parse(item.arguments || '{}')
|
||||
: (item.arguments ?? {});
|
||||
const task = typeof args.task === 'string' && args.task ? args.task : '?';
|
||||
const label = args.background ? 'Background sub-agent' : 'Sub-agent';
|
||||
name = `${label}: "${task.length > 60 ? `${task.slice(0, 60)}...` : task}"`;
|
||||
name = String(args.title || args.task || 'Sub-agent').slice(0, 60);
|
||||
} catch {
|
||||
name = 'Sub-agent';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user