Something went wrong. Try again.
Parametric learning in your code harness.
Something went wrong. Try again.
1.6 kB · 40 lines
Python
at letta-code
1234567891011121314151617181920212223242526272829303132333435363738394041from __future__ import annotations
import sysimport unittestfrom pathlib import Path
ROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT))
from build_tool_bootstrap import build_examples # noqa: E402
class ToolBootstrapTest(unittest.TestCase): def test_builds_balanced_auditable_corpus(self) -> None: rows = build_examples() self.assertEqual(len(rows), 45) counts: dict[tuple[str, str], int] = {} for row in rows: metadata = row["metadata"] key = (metadata["language"], metadata["kind"]) counts[key] = counts.get(key, 0) + 1 self.assertTrue(row["tools"]) self.assertEqual(row["messages"][0]["role"], "user") self.assertEqual(row["messages"][-1]["role"], "assistant") calls = [call for message in row["messages"] for call in message.get("tool_calls", [])] results = [message for message in row["messages"] if message["role"] == "tool"] self.assertEqual(len(calls), len(results)) self.assertEqual({call["id"] for call in calls}, {result["tool_call_id"] for result in results}) for language in ("python", "javascript", "julia"): self.assertEqual(counts[(language, "success")], 12) self.assertEqual(counts[(language, "recovery")], 3)
def test_contains_no_project_euler_prompts(self) -> None: serialized = repr(build_examples()).lower() self.assertNotIn("project euler", serialized) self.assertNotIn("multiples of 3", serialized)
if __name__ == "__main__": unittest.main()