Spaces:
Sleeping
Sleeping
Download app/api/memories.py from appQQQ/FinDataPilot: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/appQQQ/FinDataPilot/resolve/main/app/api/memories.py
- Command line
-
hf download hf://spaces/appQQQ/FinDataPilot/app/api/memories.py
-
curl -L -o memories.py https://huggingface.co/spaces/appQQQ/FinDataPilot/resolve/main/app/api/memories.py
1.31 kB
| """User-facing controls for inspectable, erasable long-term memory.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| from fastapi import APIRouter, Depends, HTTPException | |
| from app.config import get_settings | |
| from app.security import AuthContext, require_user | |
| from app.storage.repository import ( | |
| clear_memories_for_user_async, | |
| delete_long_term_memory_for_user_async, | |
| list_long_term_memories_async, | |
| ) | |
| router = APIRouter() | |
| async def get_memories(auth: AuthContext = Depends(require_user)) -> dict[str, Any]: | |
| settings = get_settings() | |
| return { | |
| "enabled": settings.memory_enabled, | |
| "identity_scope": "this_browser", | |
| "memories": await list_long_term_memories_async(auth.user_id), | |
| } | |
| async def clear_memories(auth: AuthContext = Depends(require_user)) -> dict[str, Any]: | |
| deleted = await clear_memories_for_user_async(auth.user_id) | |
| return {"deleted": deleted} | |
| async def delete_memory( | |
| memory_id: str, auth: AuthContext = Depends(require_user) | |
| ) -> dict[str, Any]: | |
| if not await delete_long_term_memory_for_user_async(memory_id, auth.user_id): | |
| raise HTTPException(404, "Memory not found") | |
| return {"id": memory_id, "deleted": True} | |