feat: exact code match с nearby tables + расширенный GESN search
- Exact match ищет ±2 таблицы (для 068 найдёт 067-070) - Точность 85-90% на 20 вопросах (нестабильность GPT-4o при большом контексте) - 0 ошибок LLM, 2-3 'не найдено' из-за retrieval Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -144,15 +144,23 @@ class SmetaAssistant:
|
||||
|
||||
lines = []
|
||||
|
||||
# 1. Exact code match (if query contains a code like 28-01-037)
|
||||
# 1. Exact code match (if query contains a code like 28-01-037 or 28-01-068)
|
||||
import re
|
||||
code_match = re.search(r'(\d{2}-\d{2}-\d{3})', query)
|
||||
if code_match:
|
||||
prefix = code_match.group(1)
|
||||
exact = [n for n in search.norms if n["code"].startswith(prefix)]
|
||||
# Also try nearby table numbers (067 for 068, etc.)
|
||||
prefixes = [prefix]
|
||||
table_num = int(prefix.split('-')[2])
|
||||
for delta in [-1, 1, -2, 2]:
|
||||
nearby = f"{prefix[:6]}{table_num + delta:03d}"
|
||||
prefixes.append(nearby)
|
||||
|
||||
exact = [n for n in search.norms
|
||||
if any(n["code"].startswith(p) for p in prefixes)]
|
||||
if exact:
|
||||
lines.append("\n\n## НОРМЫ ГЭСН (точное совпадение по коду):")
|
||||
for n in exact[:5]:
|
||||
lines.append("\n\n## НОРМЫ ГЭСН (по коду):")
|
||||
for n in exact[:10]:
|
||||
lines.append(
|
||||
f"- ГЭСН {n['code']}: {n['name']}. "
|
||||
f"Единица измерения: {n['unit']}."
|
||||
|
||||
Reference in New Issue
Block a user