Download tests/test_voyager_learning.py from Erinaldordso/Minecraft-Friends-AI-ZeroGPU: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/spaces/Erinaldordso/Minecraft-Friends-AI-ZeroGPU/resolve/main/tests/test_voyager_learning.py
- Command line
-
hf download hf://spaces/Erinaldordso/Minecraft-Friends-AI-ZeroGPU/tests/test_voyager_learning.py
-
curl -L -o test_voyager_learning.py https://huggingface.co/spaces/Erinaldordso/Minecraft-Friends-AI-ZeroGPU/resolve/main/tests/test_voyager_learning.py
2.38 kB
| """Regression tests for persistent Voyager learning memory.""" | |
| from __future__ import annotations | |
| import json | |
| import sys | |
| import tempfile | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(ROOT)) | |
| from voyager_learning import build_learning_state, learning_path, read_learning_state, refresh_learning_state | |
| def test_persistent_learning_memory() -> None: | |
| with tempfile.TemporaryDirectory() as tmp: | |
| ckpt = Path(tmp) / "ckpt" | |
| (ckpt / "curriculum").mkdir(parents=True) | |
| (ckpt / "skill").mkdir(parents=True) | |
| (ckpt / "curriculum" / "completed_tasks.json").write_text( | |
| json.dumps([ | |
| "Place 1 stone", | |
| "Place 1 oak_planks", | |
| "Place 1 glass", | |
| "Place 1 bricks", | |
| "Build 1 wall", | |
| ]), | |
| encoding="utf-8", | |
| ) | |
| (ckpt / "curriculum" / "failed_tasks.json").write_text( | |
| json.dumps(["Mine 1 glass"]), encoding="utf-8" | |
| ) | |
| (ckpt / "skill" / "skills.json").write_text( | |
| json.dumps({ | |
| "placeStone": {"code": "async function placeStone(bot) {}"}, | |
| "buildWall": {"code": "async function buildWall(bot) {}"}, | |
| }), | |
| encoding="utf-8", | |
| ) | |
| state = build_learning_state(ckpt, "Naldo_Bot") | |
| assert state["completed_count"] == 5 | |
| assert state["failed_count"] == 1 | |
| assert state["skill_count"] == 2 | |
| assert state["bucket_persistent"] is False | |
| # Reporting only: no mastery gate and no closed build catalog. | |
| assert state["capabilities"]["place"]["distinct_count"] == 4 | |
| assert "mastered" not in state["capabilities"]["place"] | |
| assert "threshold" not in state["capabilities"]["place"] | |
| assert "build_projects" not in state | |
| assert state["curriculum_owner"] == "upstream CurriculumAgent" | |
| written = refresh_learning_state(ckpt, "Naldo_Bot") | |
| assert learning_path(ckpt).exists() | |
| loaded = read_learning_state(ckpt) | |
| assert loaded["bot_username"] == "Naldo_Bot" | |
| assert loaded["skill_count"] == written["skill_count"] | |
| assert loaded["sources"]["skills"] == "skill/skills.json" | |
| if __name__ == "__main__": | |
| test_persistent_learning_memory() | |
| print("PASS persistent Voyager learning memory") | |