mirror of
https://github.com/andrewyng/openworker.git
synced 2026-09-14 00:00:58 +00:00
Memory V1: remembered facts, your instructions, one screen
Coworkers remember durable things you tell them and use them in future sessions. One Settings screen lists everything remembered - edit, delete, or stop new saves; standing instructions ride along. Knowledge is session-stable, the save switch is per-message; sqlite gains a summary column via in-place migration.
This commit is contained in:
+27
-1
@@ -644,10 +644,36 @@ def create_app(manager: SessionManager) -> FastAPI:
|
||||
|
||||
@app.post("/v1/memory")
|
||||
def add_memory(body: dict) -> dict[str, Any]:
|
||||
body = body or {}
|
||||
return manager.add_memory(
|
||||
body.get("content", ""), body.get("scope", "workspace")
|
||||
str(body.get("content", "")), str(body.get("scope", "workspace"))
|
||||
)
|
||||
|
||||
# Declared before the /{item_id} routes so "settings" can never be parsed as an id.
|
||||
@app.get("/v1/memory/settings")
|
||||
def memory_settings() -> dict[str, Any]:
|
||||
return manager.get_memory_settings()
|
||||
|
||||
@app.put("/v1/memory/settings")
|
||||
def memory_settings_put(body: dict) -> dict[str, Any]:
|
||||
body = body or {}
|
||||
return manager.set_memory_settings(
|
||||
enabled=bool(body["enabled"]) if "enabled" in body else None,
|
||||
user_rules=str(body["user_rules"]) if "user_rules" in body else None,
|
||||
)
|
||||
|
||||
@app.patch("/v1/memory/{item_id}")
|
||||
def memory_patch(item_id: int, body: dict) -> dict[str, Any]:
|
||||
return manager.update_memory(item_id, str((body or {}).get("content", "")))
|
||||
|
||||
@app.delete("/v1/memory/{item_id}")
|
||||
def memory_delete(item_id: int) -> dict[str, Any]:
|
||||
return manager.delete_memory(item_id)
|
||||
|
||||
@app.delete("/v1/memory")
|
||||
def memory_delete_all() -> dict[str, Any]:
|
||||
return manager.delete_all_memory()
|
||||
|
||||
@app.post("/v1/chat/completions")
|
||||
def chat_completions(body: dict) -> dict[str, Any]:
|
||||
model = body.get("model", manager.model)
|
||||
|
||||
Reference in New Issue
Block a user