fix: auto-route — файлы в директории → всегда Claude Code
GLM-5 галлюцинировал данные из сметы (927 км, 2866 м³) которых не было в выборке из 60 строк. Недопустимо для сметного дела. Теперь: если в рабочей директории есть файлы → Claude Code (читает всё). Вопросы без файлов → GLM-5 (быстро, точно из CAG). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user