Fix: Unified Context Memory between Web and Telegram
This commit is contained in:
7
main.py
7
main.py
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user