mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-04-28 19:51:11 +00:00
fix: queue duplicate message
This commit is contained in:
parent
2c0a64189e
commit
75248049c3
3 changed files with 36 additions and 6 deletions
|
|
@ -1,20 +1,26 @@
|
|||
from agent import AgentContext
|
||||
from python.helpers.api import ApiHandler, Input, Output, Request, Response
|
||||
from python.helpers import message_queue as mq
|
||||
|
||||
|
||||
class PluginScanQueue(ApiHandler):
|
||||
"""Set progress to 'Queued' without starting the agent or logging the prompt."""
|
||||
"""Log the scan prompt into a chat. Optionally set progress to 'Queued'."""
|
||||
|
||||
async def process(self, input: Input, request: Request) -> Output:
|
||||
ctxid: str = input.get("context", "")
|
||||
text: str = input.get("text", "")
|
||||
queued: bool = input.get("queued", False)
|
||||
|
||||
if not ctxid:
|
||||
return Response("Missing 'context'.", 400)
|
||||
if not ctxid or not text:
|
||||
return Response("Missing 'context' or 'text'.", 400)
|
||||
|
||||
context = AgentContext.get(ctxid)
|
||||
if context is None:
|
||||
return Response(f"Context {ctxid} not found.", 404)
|
||||
|
||||
context.log.set_progress("icon://hourglass_empty Queued - waiting for another scan to finish", 0, True)
|
||||
mq.log_user_message(context, text, [])
|
||||
|
||||
if queued:
|
||||
context.log.set_progress("icon://hourglass_empty Queued - waiting for another scan to finish", 0, True)
|
||||
|
||||
return {"ok": True, "context": ctxid}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue