Added iteration loading
This commit is contained in:
@@ -2,11 +2,13 @@ from aiohttp import web
|
||||
import json
|
||||
import asyncio
|
||||
|
||||
|
||||
from ..auto_approver import AutoApprover
|
||||
from ..entry.entry_factory import EntryFactory
|
||||
from ..iteration_parser import IterationParser
|
||||
from ..web_agent import WebAgent
|
||||
from ..web_io_buffer import WebIOBuffer
|
||||
from ..working_memory import WorkingMemory
|
||||
from ..entry.entry_factory import EntryFactory
|
||||
|
||||
class Api:
|
||||
def __init__(
|
||||
@@ -47,6 +49,7 @@ class Api:
|
||||
self._app.router.add_delete("/api/memory/entry/{id}", self._delete_entry)
|
||||
self._app.router.add_post("/api/memory/entry/{id}/reset", self._reset_entry)
|
||||
self._app.router.add_post("/api/memory/entry/{id}/update", self._update_entry)
|
||||
self._app.router.add_post("/api/memory/load_iteration", self._load_iteration)
|
||||
|
||||
async def _run_inference(self, request: web.Request) -> web.Response:
|
||||
"""Start inference on specified LLM."""
|
||||
@@ -253,4 +256,18 @@ class Api:
|
||||
entry.notify_change()
|
||||
return web.Response(status=200)
|
||||
except ValueError as e:
|
||||
return web.Response(status=400, text=str(e))
|
||||
return web.Response(status=400, text=str(e))
|
||||
|
||||
async def _load_iteration(self, request: web.Request) -> web.Response:
|
||||
"""Load entries from iteration XML content into working memory"""
|
||||
data = await request.json()
|
||||
content = data.get("content")
|
||||
if not content:
|
||||
return web.Response(status=400, text="Missing content in request body")
|
||||
|
||||
entries = IterationParser.parse_iteration(content, self._io_buffer)
|
||||
|
||||
for entry in entries:
|
||||
self._working_memory.add_entry(entry)
|
||||
|
||||
return web.Response(status=200)
|
||||
|
||||
Reference in New Issue
Block a user