""" TENSOR Runtime Lab — HuggingFace Space Transformer-Native Computational Paradigm Research Demo Author: ashutoshzade """ import gradio as gr import anthropic import json import time import os import pandas as pd import numpy as np from datetime import datetime from benchmark import run_icu_benchmark, get_benchmark_summary from latent_inspector import get_attention_summary, get_wolfram_verification # --------------------------------------------------------------------------- # Anthropic client — set ANTHROPIC_API_KEY in HF Space secrets # --------------------------------------------------------------------------- def get_client(): api_key = os.environ.get("ANTHROPIC_API_KEY", "") if not api_key: raise ValueError("ANTHROPIC_API_KEY not set. Add it in Space Settings → Secrets.") return anthropic.Anthropic(api_key=api_key) # --------------------------------------------------------------------------- # TAB 1 — TENSOR Runtime: algorithm selection + implementation # --------------------------------------------------------------------------- RUNTIME_SYSTEM = """You are the TENSOR Runtime — a transformer-native computational engine. When given a problem description and sample data, you: 1. SELECT the single best algorithm for the task (be specific: e.g. "XGBoost classifier" not just "tree model") 2. STATE WHY in one sentence referencing the data characteristics 3. IMPLEMENT a clean, runnable Python snippet (use sklearn, numpy, pandas only) 4. RATE your confidence 1-10 and explain any caveats Respond in this exact JSON structure: { "algorithm": "", "rationale": "", "code": "", "confidence": , "caveats": "", "complexity": "