Spaces:
Runtime error
Runtime error
Download backend/app/routers/memory.py from firebird-technologies/NoteStack-Test: direct link, hf CLI and curl.
- Browser
- Download file 848 Bytes
-
https://huggingface.co/spaces/firebird-technologies/NoteStack-Test/resolve/main/backend/app/routers/memory.py
- Command line
-
hf download hf://spaces/firebird-technologies/NoteStack-Test/backend/app/routers/memory.py
-
curl -L -o memory.py https://huggingface.co/spaces/firebird-technologies/NoteStack-Test/resolve/main/backend/app/routers/memory.py
848 Bytes
| from fastapi import APIRouter, Depends, HTTPException | |
| from pydantic import BaseModel, Field | |
| from app.auth import Ctx, get_ctx | |
| from app.services import memory | |
| router = APIRouter(prefix="/api/memory", tags=["memory"]) | |
| class FactIn(BaseModel): | |
| value: str = Field(min_length=1, max_length=memory.MAX_VALUE) | |
| def list_facts(ctx: Ctx = Depends(get_ctx)): | |
| return {"items": memory.list_facts(ctx.db, ctx.workspace.id), "limit": memory.MAX_FACTS} | |
| def put_fact(key: str, body: FactIn, ctx: Ctx = Depends(get_ctx)): | |
| return memory.set_fact(ctx.db, ctx.workspace.id, key, body.value) | |
| def delete_fact(key: str, ctx: Ctx = Depends(get_ctx)): | |
| if not memory.delete_fact(ctx.db, ctx.workspace.id, key): | |
| raise HTTPException(404, "Note not found") | |
| return {"ok": True} | |