兼容新版 EverOS memory API
This commit is contained in:
@ -403,7 +403,7 @@ class EverOSMemorySystemClient:
|
||||
async def append_message(self, user_id: str, session_id: str, role: str, content: str) -> dict[str, Any]:
|
||||
async with self._client() as client:
|
||||
response = await client.post(
|
||||
"/api/v1/memories",
|
||||
"/api/v1/memory/add",
|
||||
json=self.build_message_payload(user_id=user_id, session_id=session_id, role=role, content=content),
|
||||
)
|
||||
response.raise_for_status()
|
||||
@ -414,7 +414,6 @@ class EverOSMemorySystemClient:
|
||||
sender_id = "assistant" if everos_role == "assistant" else user_id
|
||||
timestamp = int(datetime.now(timezone.utc).timestamp() * 1000)
|
||||
return {
|
||||
"user_id": user_id,
|
||||
"session_id": session_id,
|
||||
"messages": [
|
||||
{
|
||||
@ -430,25 +429,30 @@ class EverOSMemorySystemClient:
|
||||
|
||||
async def flush(self, user_id: str, session_id: str) -> dict[str, Any]:
|
||||
async with self._client() as client:
|
||||
response = await client.post("/api/v1/memories/flush", json={"user_id": user_id, "session_id": session_id})
|
||||
response = await client.post(
|
||||
"/api/v1/memory/flush",
|
||||
json={"session_id": session_id},
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
async def search(self, user_id: str, session_id: str | None, query: str, method: str, limit: int) -> dict[str, Any]:
|
||||
filters: dict[str, Any] = {"user_id": user_id}
|
||||
filters: dict[str, Any] = {}
|
||||
if session_id:
|
||||
filters["session_id"] = session_id
|
||||
payload: dict[str, Any] = {
|
||||
"user_id": user_id,
|
||||
"query": query,
|
||||
"method": method,
|
||||
"top_k": limit,
|
||||
"include_profile": True,
|
||||
}
|
||||
if filters:
|
||||
payload["filters"] = filters
|
||||
async with self._client() as client:
|
||||
response = await client.post(
|
||||
"/api/v1/memories/search",
|
||||
json={
|
||||
"query": query,
|
||||
"method": method,
|
||||
"memory_types": ["episodic_memory", "profile", "raw_message"],
|
||||
"filters": filters,
|
||||
"top_k": limit,
|
||||
"include_original_data": True,
|
||||
},
|
||||
"/api/v1/memory/search",
|
||||
json=payload,
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
@ -456,10 +460,10 @@ class EverOSMemorySystemClient:
|
||||
async def get_profile(self, user_id: str) -> dict[str, Any]:
|
||||
async with self._client() as client:
|
||||
response = await client.post(
|
||||
"/api/v1/memories/get",
|
||||
"/api/v1/memory/get",
|
||||
json={
|
||||
"user_id": user_id,
|
||||
"memory_type": "profile",
|
||||
"filters": {"user_id": user_id},
|
||||
"page": 1,
|
||||
"page_size": 20,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user