Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions devops_agent/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import os

import click
from rich.console import Console
Expand All @@ -17,7 +18,17 @@ def cli():


def default_provider() -> str:
return "openai"
"""Automatically detect which LLM provider to use based on available API keys."""
if os.environ.get("OPENAI_API_KEY"):
return "openai"
elif os.environ.get("ANTHROPIC_API_KEY"):
return "anthropic"
elif os.environ.get("GEMINI_API_KEY"):
return "google"
else:
# If nothing found, fallback and warn
console.print("[bold yellow]⚠️ No API key found. Defaulting to OpenAI (if set later).[/bold yellow]")
return "openai"


@cli.command()
Expand All @@ -31,7 +42,7 @@ def run(log_file, provider, query, output, format, interactive):
"""Run the DevOps agent with specified options"""

if not provider:
console.print("[yellow]No provider specified, defaulting to openai[/yellow]")
console.print("[yellow]No provider specified[/yellow]")
provider = default_provider()

# Interactive mode
Expand Down