diff --git a/backend/main.py b/backend/main.py index 1c99d28..00a691a 100644 --- a/backend/main.py +++ b/backend/main.py @@ -2,6 +2,7 @@ import json import logging +import os import time from datetime import datetime from typing import List, Dict, Any, Optional @@ -9,7 +10,8 @@ from contextlib import asynccontextmanager from fastapi import FastAPI, HTTPException, BackgroundTasks, Depends, Security, Request from fastapi.middleware.cors import CORSMiddleware -from fastapi.responses import JSONResponse, StreamingResponse +from fastapi.responses import JSONResponse, StreamingResponse, FileResponse +from fastapi.staticfiles import StaticFiles import structlog import asyncio from slowapi import Limiter, _rate_limit_exceeded_handler @@ -916,6 +918,29 @@ except Exception as e: logger.error(f"Failed to mount MCP server: {e}") +# Serve frontend static files +# This must be AFTER all API routes to avoid catching API requests +FRONTEND_DIR = "/app/frontend" + +@app.get("/") +async def serve_frontend_root(): + """Serve the frontend application.""" + index_path = os.path.join(FRONTEND_DIR, "index.html") + if os.path.exists(index_path): + return FileResponse(index_path) + return JSONResponse( + status_code=404, + content={"error": "Frontend not found", "path": index_path} + ) + +# Mount static files for any assets in the frontend directory (CSS, JS, images, etc.) +if os.path.exists(FRONTEND_DIR): + app.mount("/static", StaticFiles(directory=FRONTEND_DIR), name="static") + logger.info(f"Frontend static files mounted from {FRONTEND_DIR}") +else: + logger.warning(f"Frontend directory not found at {FRONTEND_DIR}") + + if __name__ == "__main__": import uvicorn diff --git a/backend/mem0_manager.py b/backend/mem0_manager.py index b3e226f..ca62707 100644 --- a/backend/mem0_manager.py +++ b/backend/mem0_manager.py @@ -82,10 +82,11 @@ class Mem0Manager: }, }, "embedder": { - "provider": "ollama", + "provider": "openai", "config": { "model": settings.embedding_model, - "ollama_base_url": settings.ollama_base_url, + "api_key": settings.openai_api_key, + "openai_base_url": settings.openai_base_url, "embedding_dims": settings.embedding_dims, }, }, diff --git a/docker-compose.yml b/docker-compose.yml index 3eabf28..3a297c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: # Neo4j with APOC for graph relationships neo4j: - image: neo4j:5.26.4 + image: neo4j:latest container_name: mem0-neo4j environment: NEO4J_AUTH: ${NEO4J_AUTH:-neo4j/mem0_neo4j_password} @@ -82,6 +82,12 @@ services: condition: service_healthy neo4j: condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/health"] + interval: 30m + timeout: 30s + retries: 3 + start_period: 10s restart: unless-stopped volumes: - ./backend:/app @@ -96,6 +102,6 @@ volumes: neo4j_plugins: networks: - mem0_network: npm_network: external: true + mem0_network: