File size: 702 Bytes
2651a17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# app/api/memory.py

from fastapi import APIRouter
from app.memory.memory_client import MemoryClient

router = APIRouter(prefix="/memory", tags=["memory"])


@router.post("/add")
def add_memory(user_id: str, content: str):
    """
    Store long-term memory in Qdrant cloud.
    """

    MemoryClient.add_memory(
        user_id=user_id,
        content=content,
    )

    return {
        "status": "stored",
        "user_id": user_id,
    }


@router.get("/search")
def search_memory(user_id: str, query: str):
    """
    Search memory in Qdrant.
    """

    results = MemoryClient.search_memory(
        user_id=user_id,
        query=query,
    )

    return {
        "results": results,
    }