-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (21 loc) · 676 Bytes
/
main.py
File metadata and controls
27 lines (21 loc) · 676 Bytes
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
# main.py
import asyncio
import sys
if sys.platform.startswith('win'):
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
from fastapi import FastAPI
from pydantic import BaseModel
from app import run_memory_chat
app = FastAPI(title="MCP Server - AI Assistant")
class ChatRequest(BaseModel):
message: str
@app.get("/")
async def root():
return {"message": "MCP Server is running. Use POST /chat to talk to the assistant."}
@app.post("/chat")
async def chat(req: ChatRequest):
try:
response = await run_memory_chat(req.message)
return {"response": response}
except Exception as e:
return {"error": str(e)}