mirror of
https://github.com/open-webui/computer.git
synced 2026-11-24 14:30:22 -05:00
refac
This commit is contained in:
1 parent
72e9b35cb4
commit
fc07e9bcad
3 files changed
+43
-15
No files matched your search
@@ -218,6 +218,8 @@ class Chat(Base):
|
||||
.where(
|
||||
Chat.user_id == user_id,
|
||||
workspace.in_(paths),
|
||||
Chat.meta["internal"].as_boolean().is_not(True),
|
||||
Chat.meta["subagent"].as_boolean().is_not(True),
|
||||
Chat.updated_at > func.coalesce(Chat.last_read_at, 0),
|
||||
)
|
||||
.group_by(workspace)
|
||||
|
||||
@@ -202,6 +202,7 @@ async def _inject_completion(record: dict[str, Any]) -> None:
|
||||
from cptr.utils.chat_task import get_pending_input_lock, start_task
|
||||
|
||||
assistant_msg = None
|
||||
direct_timer_completion = False
|
||||
async with get_pending_input_lock(parent_chat_id):
|
||||
all_msgs = await ChatMessage.get_all_by_chat(parent_chat_id)
|
||||
active = any(m.role == "assistant" and not m.done for m in all_msgs)
|
||||
@@ -216,29 +217,55 @@ async def _inject_completion(record: dict[str, Any]) -> None:
|
||||
if active:
|
||||
meta["async_subagent_pending"] = True
|
||||
|
||||
user_msg = await ChatMessage.create(
|
||||
chat_id=parent_chat_id,
|
||||
role="user",
|
||||
content=content,
|
||||
parent_id=parent_id,
|
||||
model=model_id,
|
||||
meta=meta,
|
||||
created_at=now_ms(),
|
||||
)
|
||||
|
||||
if not active:
|
||||
if record.get("timer_chat_id") and not active:
|
||||
direct_timer_completion = True
|
||||
meta["timer_completion"] = True
|
||||
assistant_msg = await ChatMessage.create(
|
||||
chat_id=parent_chat_id,
|
||||
role="assistant",
|
||||
content="",
|
||||
parent_id=user_msg.id,
|
||||
content=record.get("summary") or "Timer completed.",
|
||||
parent_id=parent_id,
|
||||
model=model_id,
|
||||
done=False,
|
||||
done=True,
|
||||
meta=meta,
|
||||
created_at=now_ms(),
|
||||
)
|
||||
await Chat.update_current_message(parent_chat_id, assistant_msg.id, now_ms())
|
||||
else:
|
||||
user_msg = await ChatMessage.create(
|
||||
chat_id=parent_chat_id,
|
||||
role="user",
|
||||
content=content,
|
||||
parent_id=parent_id,
|
||||
model=model_id,
|
||||
meta=meta,
|
||||
created_at=now_ms(),
|
||||
)
|
||||
|
||||
if not active:
|
||||
assistant_msg = await ChatMessage.create(
|
||||
chat_id=parent_chat_id,
|
||||
role="assistant",
|
||||
content="",
|
||||
parent_id=user_msg.id,
|
||||
model=model_id,
|
||||
done=False,
|
||||
created_at=now_ms(),
|
||||
)
|
||||
await Chat.update_current_message(parent_chat_id, assistant_msg.id, now_ms())
|
||||
|
||||
await export_chat_to_file(parent_chat_id)
|
||||
if direct_timer_completion:
|
||||
await emit_to_user(
|
||||
user_id,
|
||||
{
|
||||
"chat_id": parent_chat_id,
|
||||
"message_id": assistant_msg.id,
|
||||
"pending_inputs_processed": True,
|
||||
},
|
||||
)
|
||||
return
|
||||
|
||||
if not assistant_msg:
|
||||
await emit_to_user(
|
||||
user_id,
|
||||
|
||||
@@ -2620,7 +2620,6 @@ GLOBAL_CHAT_DISABLED_TOOLS = {
|
||||
*BUILTIN_TOOL_GROUPS["browser"],
|
||||
*BUILTIN_TOOL_GROUPS["automations"],
|
||||
*BUILTIN_TOOL_GROUPS["images"],
|
||||
*BUILTIN_TOOL_GROUPS["subagents"],
|
||||
"manage_skill",
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user