File size: 2,197 Bytes
75c480e 94de9e9 75c480e 930f127 75c480e 930f127 75c480e 930f127 94de9e9 930f127 75c480e 94de9e9 e66bd94 94de9e9 e66bd94 6f25d16 930f127 94de9e9 e66bd94 94de9e9 930f127 94de9e9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # /// 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()
|