import os import json import glob import gradio as gr from huggingface_hub import snapshot_download DATASET_REPO_ID = "PeacebinfLow/mindseye-android-os-data" # change if needed def load_apps_from_dataset(): local_dir = snapshot_download( repo_id=DATASET_REPO_ID, repo_type="dataset", local_dir="dataset_cache", local_dir_use_symlinks=False ) app_files = glob.glob(os.path.join(local_dir, "apps", "*", "*.json")) apps = [] errors = [] for fp in app_files: try: with open(fp, "r", encoding="utf-8") as f: obj = json.load(f) # minimal sanity check if "id" in obj and "name" in obj and "category" in obj: apps.append(obj) else: errors.append(f"Missing required fields in: {fp}") except Exception as e: errors.append(f"{fp}: {e}") # stable ordering apps.sort(key=lambda a: (a.get("category", ""), a.get("name", ""))) return apps, errors def build_html(apps, source_label="snapshot_download"): apps_json = json.dumps(apps, ensure_ascii=False) return f""" MindsEye Android OS
--:--
MindsEye
📶 87%
""" with gr.Blocks() as demo: apps, errors = load_apps_from_dataset() html = build_html(apps) gr.HTML(html) if errors: gr.Markdown("### Dataset Load Warnings") gr.Markdown("```log\n" + "\n".join(errors) + "\n```") demo.launch()