import gradio as gr from engine import get_next_planet_state, HabitabilityStatus import time with open('assets/style.css', 'r', encoding='utf-8') as f: RAW_CSS = f.read() with open('assets/planet.js', 'r', encoding='utf-8') as f: RAW_JS = f.read() HEAD_INJECT = f""" """ def init_llm_eager(): print("[AeroSphere] Awakening AeroSphere Cloud Endpoints...") try: from engine import init_llm init_llm() except Exception as e: print(f"Eager loading failed: {e}") print("[AeroSphere] Neural link established. Resolving UI.") return "READY" def handle_interaction(user_input, history, core_state): try: from engine import get_next_planet_state state = get_next_planet_state(user_input, history, core_state) new_core_state = state.model_dump(mode='json') new_core_state["entities"] = [] new_core_state_str = __import__('json').dumps(new_core_state) # Failsafe overlay hide if eager load lagged hide_overlay_str = "" new_history = history + [{"role": "user", "content": user_input}, {"role": "assistant", "content": state.narrative}] history_html = '
Crash State Isolated.",
"{}",
core_state,
'