replace main with lightweight memory gateway
This commit is contained in:
41
core/everos_client.py
Normal file
41
core/everos_client.py
Normal file
@ -0,0 +1,41 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
class EverOSClient:
|
||||
def __init__(self, base_url: str, timeout: float = 120.0) -> None:
|
||||
self.base_url = base_url.rstrip("/")
|
||||
self.timeout = timeout
|
||||
|
||||
async def add_memory(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
return await self._post("/api/v1/memory/add", payload)
|
||||
|
||||
async def flush_memory(
|
||||
self,
|
||||
session_id: str,
|
||||
app_id: str,
|
||||
project_id: str,
|
||||
) -> dict[str, Any]:
|
||||
return await self._post(
|
||||
"/api/v1/memory/flush",
|
||||
{
|
||||
"session_id": session_id,
|
||||
"app_id": app_id,
|
||||
"project_id": project_id,
|
||||
},
|
||||
)
|
||||
|
||||
async def search_memory(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
return await self._post("/api/v1/memory/search", payload)
|
||||
|
||||
async def _post(self, path: str, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
async with httpx.AsyncClient(
|
||||
base_url=self.base_url,
|
||||
timeout=self.timeout,
|
||||
) as client:
|
||||
response = await client.post(path, json=payload)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
Reference in New Issue
Block a user