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
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:
@@ -0,0 +1,49 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
|
||||
|
||||
def load(name):
|
||||
spec = importlib.util.spec_from_file_location(name, HERE / f"{name}.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_sesame_tag_categories_are_explicit():
|
||||
sesame = load("run_sesame")
|
||||
assert sesame.category("hello <laughs> there") == "laugh"
|
||||
assert sesame.category("hello <giggle> there") == "giggle"
|
||||
assert sesame.category("hello <sighs> there") == "sigh"
|
||||
assert sesame.category("hello there") == "neutral"
|
||||
|
||||
|
||||
def test_orpheus_collator_masks_label_padding():
|
||||
orpheus = load("run_orpheus")
|
||||
rows = [
|
||||
{"input_ids": [1, 2], "labels": [1, 2], "attention_mask": [1, 1]},
|
||||
{"input_ids": [3], "labels": [3], "attention_mask": [1]},
|
||||
]
|
||||
batch = orpheus.PadCollator(9)(rows)
|
||||
assert batch["input_ids"].tolist() == [[1, 2], [3, 9]]
|
||||
assert batch["labels"].tolist() == [[1, 2], [3, -100]]
|
||||
assert batch["attention_mask"].tolist() == [[1, 1], [1, 0]]
|
||||
|
||||
|
||||
def test_sesame_collator_stacks_all_model_inputs():
|
||||
sesame = load("run_sesame")
|
||||
rows = [{"input_ids": torch.tensor([1, 2]), "labels": torch.tensor([3, 4])}] * 2
|
||||
batch = sesame.TensorCollator()(rows)
|
||||
assert batch["input_ids"].shape == (2, 2)
|
||||
assert batch["labels"].shape == (2, 2)
|
||||
|
||||
|
||||
def test_sha256_is_stable(tmp_path):
|
||||
analysis = load("analyze_campaign")
|
||||
path = tmp_path / "artifact"
|
||||
path.write_bytes(b"experiment-8-6")
|
||||
assert analysis.sha256(path) == "b07a691b33e493299473b6323258c9d643b2981d6de43e8c8adc3c4edc222d15"
|
||||
Reference in New Issue
Block a user