#!/usr/bin/env python3 """Load normalized interactions and individual LeRobot exports from the Hub.""" import json import pathlib from datasets import load_dataset from huggingface_hub import snapshot_download def load_interactions(stream='policy', split='train'): return load_dataset(f'LV-Robotics-Lab/pi-embodied-{stream}-interactions', split=split) def as_chat(row): """OpenAI-style messages, including tool calls and remote image URLs.""" return json.loads(row['messages_json']) def load_execution_export(name, revision='main'): from lerobot.datasets.lerobot_dataset import LeRobotDataset repo = 'LV-Robotics-Lab/pi-embodied-policy-interactions' snapshot = pathlib.Path(snapshot_download(repo, repo_type='dataset', revision=revision, allow_patterns=[f'lerobot/{name}/**'])) root = snapshot/'lerobot'/name if not (root/'meta/info.json').exists(): raise FileNotFoundError(f'Unknown execution export: {name}') return LeRobotDataset(repo_id=repo, root=root, download_videos=False)