Release NetExpert 0.2.1 with focused evidence lookup
NetExpert package / package (push) Successful in 11s

This commit is contained in:
ВяткинАртём committed 2026-11-27 15:46:29 +03:00
1 parent 233d04d238
commit 05f6809f4d
8 files changed
+191 -55

No files matched your search

+20 -6
View File
@@ -8,6 +8,8 @@ from urllib.parse import unquote
CASES = Path(__file__).with_name("cases.json")
URL = re.compile(r"""https?://[^\s<>()\[\]"`']+""")
SEARCH_WORD = re.compile(r"[^\W_]+")
MAX_QUERY_WORDS = 10
class EvaluationError(ValueError):
@@ -40,6 +42,7 @@ def replay(case, calls):
if len(calls) > len(steps):
raise EvaluationError(f"Call budget exceeded ({len(steps)} total)")
outcomes = []
previous_topics = set()
for number, (call, step) in enumerate(zip(calls, steps), 1):
context = f"Call {number}"
if not isinstance(call, dict) or call.get("tool") != step["tool"]:
@@ -55,11 +58,18 @@ def replay(case, calls):
query = arguments.get("query")
if not isinstance(query, str) or not query.strip():
raise EvaluationError(f"{context}: expected a search query")
if step.get("refine_query"):
previous = calls[number - 2]["arguments"]["query"]
normalized = " ".join(query.casefold().split())
if normalized == " ".join(previous.casefold().split()):
raise EvaluationError(f"{context}: expected a refined query")
if len(SEARCH_WORD.findall(query)) > MAX_QUERY_WORDS:
raise EvaluationError(f"{context}: expected a short search query")
topics = {
pattern
for pattern in case["query_topics"]
if re.search(rf"\b(?:{pattern})\b", query, re.IGNORECASE)
}
if not topics:
raise EvaluationError(f"{context}: expected an on-topic search query")
if step.get("refine_query") and topics == previous_topics:
raise EvaluationError(f"{context}: expected a refined query")
previous_topics = topics
outcomes.append(step["response"])
return outcomes
@@ -84,7 +94,8 @@ def grade(case, trace):
for citation in case.get("citations", []):
if citation not in links:
raise EvaluationError(f"Missing citation: {citation}")
normalized_answer = answer.casefold()
prose = URL.sub("", answer)
normalized_answer = prose.casefold()
for term in case.get("answer_contains", []):
if term.casefold() not in normalized_answer:
raise EvaluationError(f"Missing answer context: {term}")
@@ -93,6 +104,9 @@ def grade(case, trace):
raise EvaluationError(
f"Missing answer context: {' or '.join(alternatives)}"
)
for check, pattern in case.get("answer_evidence", {}).items():
if not re.search(pattern, prose, re.IGNORECASE):
raise EvaluationError(f"Missing answer evidence: {check}")
web_calls = sum(call["tool"] == "web" for call in calls)
return {
"skill": skill,