Spaces:
Paused
Paused
Download agent_zero_framework/python/api/chat_remove.py from Oldmangrizzz/Agent-Node: direct link, hf CLI and curl.
- Browser
- Download file 833 Bytes
-
https://huggingface.co/spaces/Oldmangrizzz/Agent-Node/resolve/main/agent_zero_framework/python/api/chat_remove.py
- Command line
-
hf download hf://spaces/Oldmangrizzz/Agent-Node/agent_zero_framework/python/api/chat_remove.py
-
curl -L -o chat_remove.py https://huggingface.co/spaces/Oldmangrizzz/Agent-Node/resolve/main/agent_zero_framework/python/api/chat_remove.py
833 Bytes
| from python.helpers.api import ApiHandler, Input, Output, Request | |
| from agent import AgentContext | |
| from python.helpers import persist_chat | |
| from python.helpers.task_scheduler import TaskScheduler | |
| class RemoveChat(ApiHandler): | |
| async def process(self, input: Input, request: Request) -> Output: | |
| ctxid = input.get("context", "") | |
| context = AgentContext.use(ctxid) | |
| if context: | |
| # stop processing any tasks | |
| context.reset() | |
| AgentContext.remove(ctxid) | |
| persist_chat.remove_chat(ctxid) | |
| scheduler = TaskScheduler.get() | |
| await scheduler.reload() | |
| tasks = scheduler.get_tasks_by_context_id(ctxid) | |
| for task in tasks: | |
| await scheduler.remove_task_by_uuid(task.uuid) | |
| return { | |
| "message": "Context removed.", | |
| } | |