add clear memory to server_openai

This commit is contained in:
2026-01-26 18:27:55 +08:00
parent a99408854d
commit c339457182

View File

@@ -210,6 +210,7 @@ async def root():
"message": "OpenAI-compatible Chat API",
"endpoints": [
"/v1/chat/completions",
"/v1/memory (DELETE)",
"/health"
]
}
@@ -220,6 +221,17 @@ async def health():
return {"status": "healthy"}
@app.delete("/v1/memory")
async def delete_memory():
"""Delete all conversation memory/history."""
try:
await pipeline.aclear_memory()
return JSONResponse(content={"status": "success", "message": "Memory cleared"})
except Exception as e:
logger.error(f"Memory deletion error: {e}")
raise HTTPException(status_code=500, detail=str(e))
if __name__ == "__main__":
uvicorn.run(
"server_openai:app",