mirror of
https://github.com/open-webui/computer.git
synced 2026-12-05 11:07:56 -05:00
refac
This commit is contained in:
1 parent
988582f548
commit
bbe3912e79
8 files changed
+106
-123
No files matched your search
@@ -21,27 +21,12 @@ from cptr.utils.agents.events import (
|
||||
AgentTextDelta,
|
||||
AgentToolUpdate,
|
||||
)
|
||||
from cptr.utils.agents.prompts import latest_user_text
|
||||
|
||||
|
||||
CURSOR_CAPABILITIES = {"_meta": {"parameterizedModelPicker": True}}
|
||||
|
||||
|
||||
def _prompt_from_messages(messages: list[dict[str, Any]]) -> str:
|
||||
parts: list[str] = []
|
||||
for message in messages:
|
||||
role = message.get("role", "user")
|
||||
content = message.get("content", "")
|
||||
if isinstance(content, list):
|
||||
text = "\n".join(
|
||||
str(block.get("text", "")) for block in content if isinstance(block, dict)
|
||||
)
|
||||
else:
|
||||
text = str(content or "")
|
||||
if text:
|
||||
parts.append(f"[{role}]\n{text}")
|
||||
return "\n\n".join(parts)
|
||||
|
||||
|
||||
def _auto_approve(chat_params: dict[str, Any]) -> bool:
|
||||
if chat_params.get("tool_approval_mode") == "full":
|
||||
return True
|
||||
@@ -88,7 +73,7 @@ async def run_cursor_agent(
|
||||
if model != "default":
|
||||
await client.set_model(model)
|
||||
|
||||
prompt = _prompt_from_messages(messages)
|
||||
prompt = latest_user_text(messages)
|
||||
if system_prompt:
|
||||
prompt = f"{system_prompt}\n\n{prompt}" if prompt else system_prompt
|
||||
|
||||
|
||||
Reference in new issue
Block a user