Files
task_gen_with_llm/llm_task_validator.py
2026-01-12 18:25:04 +09:00

38 lines
967 B
Python

from typing import Dict, Any
ALLOWED_SKILLS = {
"pick": ["object"],
"align": ["object", "target_fixture"],
"insert": ["object", "target_fixture"],
"release": ["object"],
}
ALLOWED_PREDICATES = {
"object_in_fixture",
"depth_in_range",
"pose_in_tolerance",
}
def validate_task_spec(task: Dict[str, Any]) -> None:
assert "skills" in task
assert "goal" in task
# ---- skills ----
for s in task["skills"]:
name = s["name"]
args = s.get("args", {})
if name not in ALLOWED_SKILLS:
raise ValueError(f"Unknown skill: {name}")
required_args = ALLOWED_SKILLS[name]
for k in required_args:
if k not in args:
raise ValueError(f"Skill {name} missing arg: {k}")
# ---- predicates ----
for p in task["goal"]["success_conditions"]:
if p["type"] not in ALLOWED_PREDICATES:
raise ValueError(f"Unknown predicate: {p['type']}")