ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s

This commit is contained in:
2026-08-20 13:12:50 +00:00
commit b119135836
10275 changed files with 3284984 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
"""Test import bootstrap for the Intuitor experiment."""
from pathlib import Path
import sys
EXPERIMENT_ROOT = Path(__file__).resolve().parents[1]
if str(EXPERIMENT_ROOT) not in sys.path:
sys.path.insert(0, str(EXPERIMENT_ROOT))
@@ -0,0 +1,18 @@
"""Regression: nested braces inside \\boxed{} must not truncate."""
from evaluate_from_cache import extract_answer_from_boxed
def test_boxed_nested_frac():
text = r"The answer is \boxed{\frac{1}{2}}"
assert extract_answer_from_boxed(text) == r"\frac{1}{2}"
def test_boxed_simple_integer():
text = r"Final answer: \boxed{42}"
assert extract_answer_from_boxed(text) == "42"
def test_boxed_deeper_nesting():
text = r"\boxed{\frac{a}{b+c}}"
assert extract_answer_from_boxed(text) == r"\frac{a}{b+c}"
@@ -0,0 +1,22 @@
"""Regression: empty sample text list must not IndexError."""
def _extract_model_output(sample_data):
text_field = sample_data.get('text', [''])
if isinstance(text_field, list):
return text_field[0] if text_field else ''
return text_field if text_field is not None else ''
def test_empty_text_list():
assert _extract_model_output({"text": []}) == ""
def test_nonempty_text_list():
assert _extract_model_output({"text": ["hello"]}) == "hello"
def test_source_guards_empty_list():
from pathlib import Path
src = (Path(__file__).resolve().parents[1] / "evaluate_from_cache.py").read_text()
assert "text_field[0] if text_field else ''" in src
@@ -0,0 +1,20 @@
"""Regression: \\frac{a}{b} and a/b must evaluate, not concatenate digit runs."""
from evaluate_from_cache import extract_and_normalize_answer, normalize_number
def test_frac_six_over_two():
assert extract_and_normalize_answer(r"\boxed{\frac{6}{2}}") == "3"
def test_plain_slash_six_over_two():
assert extract_and_normalize_answer(r"\boxed{6/2}") == "3"
def test_frac_one_half():
assert extract_and_normalize_answer(r"\boxed{\frac{1}{2}}") == "0.5"
def test_plain_integer_unchanged():
assert extract_and_normalize_answer(r"\boxed{42}") == "42"
assert normalize_number("1,234") == "1234"
@@ -0,0 +1,26 @@
"""Regression: LaTeX fractions and division with formatting/units must evaluate correctly."""
from evaluate_from_cache import extract_and_normalize_answer, normalize_number
def test_frac_thin_space_evaluates():
assert normalize_number(r"\frac{1\,000}{2}") == "500"
assert normalize_number(r"\dfrac{1\,500}{3}") == "500"
assert normalize_number(r"-\frac{1\,000}{2}") == "-500"
def test_frac_text_units_evaluates():
assert normalize_number(r"\frac{100\text{ kg}}{2}") == "50"
assert normalize_number(r"\frac{100}{2\text{ kg}}") == "50"
assert normalize_number(r"\frac{\text{100 kg}}{2}") == "50"
def test_frac_numeric_format_wrappers_evaluate():
assert normalize_number(r"\frac{\mathrm{1,000}}{2}") == "500"
assert normalize_number(r"\frac{\mathbf{6}}{2}") == "3"
def test_slash_division_with_units_and_formatting():
assert normalize_number("6/2 kg") == "3"
assert normalize_number("$6/2$") == "3"
assert normalize_number("1,000 / 2") == "500"