# /// script # requires-python = ">=3.10" # dependencies = [ # "marimo", # "openai", # ] # /// import marimo __generated_with = "0.9.0" app = marimo.App() @app.cell def _(): import marimo as mo import os import json return mo, os, json @app.cell def _(mo): mo.md( """ # ☤ Agent Zero Canvas Connected to **Agent Zero** via Hermes API (OpenAI-compatible). """ ) return @app.cell def _(mo, os, json): # --- API Key Resolution --- # Priority: AGENT_ZERO_API_KEY > parsed from API_KEYS_JSON > fallback api_key = os.environ.get("AGENT_ZERO_API_KEY", "") if not api_key: # Parse API_KEYS_JSON (same logic as verdant_claw entrypoint.sh) keys_json = os.environ.get("API_KEYS_JSON", "") if keys_json: try: keys = json.loads(keys_json) # Use the "agent_zero" key if present, otherwise fall back to "openai" api_key = keys.get("agent_zero", keys.get("openai", "")) except json.JSONDecodeError: pass if not api_key: api_key = "hermes-secret-key-123" # default for local dev # --- Base URL --- # This MUST be the public tunnel URL for your Lightning AI Studio port 8642 base_url = os.environ.get( "AGENT_ZERO_BASE_URL", "https://8642-01kmke6kkwzc5svsxjvqje6yth.cloudspaces.litng.ai/v1" ) chat = mo.ui.chat( mo.ai.llm.openai( "hermes-agent", system_message="You are Agent Zero, an advanced AI assistant with access to tools including Hermes Agent for complex reasoning, a terminal, browser, and file system.", api_key=api_key, base_url=base_url, ), prompts=[ "What tools do you have available?", "Use Hermes to analyze this problem", "Help me write a Python script", ], show_configuration_controls=True, ) chat return base_url, api_key, chat @app.cell def _(chat, mo): mo.md( f"**Messages exchanged:** {len(chat.value) if chat.value else 0}" ) return if __name__ == "__main__": app.run()