Fix: Unified Context Memory between Web and Telegram

This commit is contained in:
Marcos
2026-03-22 12:40:06 -03:00
parent 6cf2c30e59
commit 75d2a16fec
3 changed files with 16 additions and 4 deletions

View File

@@ -104,12 +104,15 @@ async def execute_smart_action(action: dict, is_auth: bool = Depends(verify_pass
@app.post("/api/chat")
async def web_chat(message: dict, is_auth: bool = Depends(verify_password)):
"""Endpoint para interagir com a IA via Web UI."""
"""Endpoint para interagir com a IA via Web UI com suporte a histórico."""
user_text = message.get("text", "")
history = message.get("history", []) # Recebe o histórico do navegador
if not user_text:
return JSONResponse(content={"reply": "Por favor, digite um comando válido."})
reply = await run_in_threadpool(query_agent, prompt=user_text)
# Passa o histórico para o query_agent manter o contexto
reply = await run_in_threadpool(query_agent, prompt=user_text, chat_history=history)
return JSONResponse(content={"reply": reply})
@app.post("/api/chat-audio")