diff --git a/main.py b/main.py index 84a8f07..906c94e 100644 --- a/main.py +++ b/main.py @@ -42,17 +42,26 @@ elif AI_BACKEND == "auto": "перенеси данн", "измени файл", "отредактируй", "скопируй", "проверь смет", "проверь файл", "открой файл", "покажи файл", "загруж", "прикреп", "файл", ".xlsx", ".docx", ".pdf", ".csv", + "внеси", "обнови", "заполни", "строк", "ячейк", "лист", + "ссрсс", "ссрс", "ведомост", "смет", ] - # Check if message references files in work directory + # Check if message references files in work directory (partial match) from claude_bridge_glm import get_work_dir as _get_wd work_dir = _get_wd(username, tab_id) - file_names = [] + has_files = False + mentions_file = False if work_dir.exists(): - file_names = [f.name.lower() for f in work_dir.iterdir() - if f.is_file() and not f.name.startswith(".")] + for f in work_dir.iterdir(): + if f.is_file() and not f.name.startswith("."): + has_files = True + # Check partial name match (without extension) + stem = f.stem.lower() + parts = [p for p in stem.replace("-", " ").replace("_", " ").split() if len(p) > 2] + if any(p in msg_lower for p in parts): + mentions_file = True + break - mentions_file = any(fn in msg_lower for fn in file_names) if file_names else False has_keyword = any(kw in msg_lower for kw in claude_keywords) use_claude = mentions_file or has_keyword