|
|
3 روز پیش | |
|---|---|---|
| .gitignore | 4 روز پیش | |
| Dockerfile | 3 روز پیش | |
| README.md | 3 روز پیش | |
| mem0server.py | 3 روز پیش | |
| requirements.txt | 4 روز پیش | |
| reset_memory.py | 4 روز پیش |
A lightweight FastAPI wrapper around mem0 providing persistent memory over a REST API, with local reranking support.
| Component | Provider | Address |
|---|---|---|
| LLM | Groq (llama-3.1-8b-instant) |
cloud |
| Vector store | Chroma | 192.168.0.200:8001 |
| Embedder | Ollama (nomic-embed-text) |
192.168.0.200:11434 |
| Reranker | local REST server | 192.168.0.200:5200 |
python -m venv mem0env
source mem0env/bin/activate
pip install fastapi uvicorn mem0 httpx
| Variable | Required | Default | Description |
|---|---|---|---|
GROQ_API_KEY |
✅ yes | — | Groq API key |
RERANKER_URL |
no | http://192.168.0.200:5200/rerank |
Local reranker endpoint |
export GROQ_API_KEY=your_key_here
# optional override:
export RERANKER_URL=http://localhost:5200/rerank
uvicorn mem0server:app --host 0.0.0.0 --port 8420
docker build -t mem0server .
Option A — pass the API key directly:
docker run -p 8420:8420 -e GROQ_API_KEY=your_key_here mem0server
Option B — use your .env file:
docker run -p 8420:8420 --env-file .env mem0server
Option C — override the reranker URL as well:
docker run -p 8420:8420 \
--env-file .env \
-e RERANKER_URL=http://192.168.0.200:5200/rerank \
mem0server
⚠️ Never bake your
.envinto the image. Always pass secrets at runtime via--env-fileor-e.
GET /healthReturns server status and configured reranker URL.
{ "status": "ok", "reranker_url": "http://192.168.0.200:5200/rerank" }
POST /memoriesAdd a memory for a user.
{ "text": "The user prefers dark mode.", "userId": "alice" }
POST /memories/searchSearch memories with reranking. Fetches limit * 3 candidates from mem0, then reranks them locally.
{ "query": "UI preferences", "userId": "alice", "limit": 5 }
rerank_score field.POST /memories/recentReturn the most recently created memories for a user.
{ "userId": "alice", "limit": 5 }
DELETE /memoriesDelete memories by filter.
{ "filter": { "user_id": "alice" } }
The server expects a reranker at RERANKER_URL accepting:
{
"query": "...",
"documents": ["doc1", "doc2", "..."],
"top_k": 5
}
And returning:
{
"results": [
{ "text": "doc1", "score": 0.99 },
{ "text": "doc2", "score": 0.87 }
]
}
If the reranker is unreachable, search falls back gracefully to the raw mem0 results.