Files
ai-crm/apps/agent/api/routers/memories.py
T
2026-10-21 23:23:48 +08:00

34 lines
925 B
Python

"""用户记忆 API。"""
from __future__ import annotations
from fastapi import APIRouter, Depends, HTTPException, status
from api.deps import current_actor, memory_service
from api.response import ok
from application.memory_service import MemoryService
from domain.models import Actor
router = APIRouter(prefix="/memories", tags=["memories"])
@router.get("")
async def list_memories(
actor: Actor = Depends(current_actor),
svc: MemoryService = Depends(memory_service),
):
items = await svc.list_public(actor)
return ok({"items": items})
@router.delete("/{memory_id}")
async def delete_memory(
memory_id: str,
actor: Actor = Depends(current_actor),
svc: MemoryService = Depends(memory_service),
):
deleted = await svc.delete(actor, memory_id)
if not deleted:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="记忆不存在")
return ok({"ok": True})