From ca49e9276cccdd7d4fff44ded7532c02ff26db38 Mon Sep 17 00:00:00 2001 From: anor Date: Tue, 24 Mar 2026 21:48:50 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20auto-route=20=E2=80=94=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D1=8B=20=D0=B2=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20=E2=86=92=20=D0=B2=D1=81=D0=B5?= =?UTF-8?q?=D0=B3=D0=B4=D0=B0=20Claude=20Code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GLM-5 галлюцинировал данные из сметы (927 км, 2866 м³) которых не было в выборке из 60 строк. Недопустимо для сметного дела. Теперь: если в рабочей директории есть файлы → Claude Code (читает всё). Вопросы без файлов → GLM-5 (быстро, точно из CAG). Co-Authored-By: Claude Opus 4.6 (1M context) --- main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index b9b4044..37f9945 100644 --- a/main.py +++ b/main.py @@ -27,10 +27,18 @@ elif AI_BACKEND == "auto": from claude_bridge import stream_claude as _stream_claude async def stream_claude(message: str, username: str, tab_id: str = "default"): - """Auto-route: file operations → Claude Code, questions → GLM-5.""" + """Auto-route: files present or file ops → Claude Code, questions → GLM-5.""" + from claude_bridge_glm import get_work_dir as _get_wd + work_dir = _get_wd(username, tab_id) + has_files = any( + f.is_file() and not f.name.startswith(".") + for f in work_dir.iterdir() + ) if work_dir.exists() else False + file_keywords = ["создай файл", "сохрани в", "запиши в excel", "сделай таблицу", - "перенеси данные", "измени файл", "отредактируй"] - use_claude = any(kw in message.lower() for kw in file_keywords) + "перенеси данные", "измени файл", "отредактируй", "проверь смет", + "проверь файл", "открой файл", "покажи файл"] + use_claude = has_files or any(kw in message.lower() for kw in file_keywords) stream_fn = _stream_claude if use_claude else _stream_glm async for chunk in stream_fn(message, username, tab_id): yield chunk