13.08.2026 20:25 перед внедрением коррекции поведения ИИ при использовании инструментов (создание флагов мусорных сообщений для очистки)

This commit is contained in:
2026-08-13 20:25:27 +03:00
parent fc1a608a5f
commit f481fffdb7
18 changed files with 1562 additions and 1254 deletions
+16 -2
View File
@@ -216,6 +216,9 @@ def get_tasks(user: Dict[str, Any] = Depends(get_current_user)):
return db_get_tasks(user_id=user["id"])
# ЧАТ С ПОДДЕРЖКОЙ ФАЙЛОВ И АВТОРИЗАЦИИ
from llm.db_tools import db_get_session_state
@app.post("/api/v1/chat")
async def chat_endpoint(
session_id: str = Form("web_session_main"),
@@ -228,6 +231,7 @@ async def chat_endpoint(
file_bytes = await file.read()
parsed_file = extract_text_from_file(file_bytes, file.filename)
# 1. Сначала обрабатываем сообщение и вызовы инструментов
reply, history = process_chat_message(
user_id=current_user["id"],
user_message=message,
@@ -235,7 +239,13 @@ async def chat_endpoint(
image_b64=parsed_file["image_b64"],
session_id=session_id
)
return {"reply": reply, "history": history}
# 2. СТРОГО ПОСЛЕ обработки проверяем, осталось ли активное превью в базе
from llm.db_tools import db_get_session_state
state = db_get_session_state(session_id)
needs_confirm = bool(state and state.get("state_type") in ["PROMPT_PREVIEW", "TASK_DELETE_PREVIEW"])
return {"reply": reply, "history": history, "needs_confirmation": needs_confirm}
@app.post("/api/v1/chat/guest")
async def guest_chat_endpoint(
@@ -255,7 +265,11 @@ async def guest_chat_endpoint(
image_b64=parsed_file["image_b64"],
session_id=session_id
)
return {"reply": reply, "history": history}
state = db_get_session_state(session_id)
needs_confirm = bool(state and state.get("state_type") == "PROMPT_PREVIEW")
return {"reply": reply, "history": history, "needs_confirmation": needs_confirm}
# === СТРОГО В КОНЦЕ: ФОЛЛБЭК СТАТИКИ ===