From 0d3bebf32d55fcb8410b3657131506a6ef79105c Mon Sep 17 00:00:00 2001 From: Dillon DuPont Date: Wed, 28 May 2025 09:25:21 -0400 Subject: [PATCH] .env fixes, use CUA_API_KEY in app.py --- libs/agent/agent/ui/gradio/app.py | 8 +++++++- scripts/playground.sh | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/agent/agent/ui/gradio/app.py b/libs/agent/agent/ui/gradio/app.py index b4f8bddd..a6dfa33c 100644 --- a/libs/agent/agent/ui/gradio/app.py +++ b/libs/agent/agent/ui/gradio/app.py @@ -445,7 +445,8 @@ def create_gradio_ui( # Check for API keys openai_api_key = os.environ.get("OPENAI_API_KEY", "") anthropic_api_key = os.environ.get("ANTHROPIC_API_KEY", "") - + cua_api_key = os.environ.get("CUA_API_KEY", "") + # Always show models regardless of API key availability openai_models = ["OpenAI: Computer-Use Preview"] anthropic_models = [ @@ -463,9 +464,11 @@ def create_gradio_ui( # Check if API keys are available has_openai_key = bool(openai_api_key) has_anthropic_key = bool(anthropic_api_key) + has_cua_key = bool(cua_api_key) print("has_openai_key", has_openai_key) print("has_anthropic_key", has_anthropic_key) + print("has_cua_key", has_cua_key) # Get Ollama models for OMNI ollama_models = get_ollama_models() @@ -747,6 +750,7 @@ if __name__ == "__main__": value="", type="password", info="Required for cloud provider", + visible=(not has_cua_key) ) with gr.Accordion("Agent Configuration", open=True): @@ -1171,6 +1175,8 @@ if __name__ == "__main__": else: # For Ollama or default OAICOMPAT (without custom key), no key needed/expected api_key = "" + + cua_cloud_api_key = cua_cloud_api_key or os.environ.get("CUA_API_KEY", "") # --- Save Settings Before Running Agent --- current_settings = { diff --git a/scripts/playground.sh b/scripts/playground.sh index 8193f022..7e7f038a 100755 --- a/scripts/playground.sh +++ b/scripts/playground.sh @@ -175,9 +175,9 @@ mkdir -p "$DEMO_DIR" # Create .env.local file with API keys (only if it doesn't exist) if [[ ! -f "$DEMO_DIR/.env.local" ]]; then cat > "$DEMO_DIR/.env.local" << EOF -# Add your API keys here -OPENAI_API_KEY=your_openai_api_key_here -ANTHROPIC_API_KEY=your_anthropic_api_key_here +# Uncomment and add your API keys here +# OPENAI_API_KEY=your_openai_api_key_here +# ANTHROPIC_API_KEY=your_anthropic_api_key_here CUA_API_KEY=your_cua_api_key_here EOF echo "📝 Created .env.local file with API key placeholders"