Spaces:
Build error
Build error
File size: 4,737 Bytes
8a682b5 | 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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | """
Configuration CLI Tool for AI Agent
Provides command-line interface for managing integration configuration,
validation, and file operations.
"""
import click
import json
from pathlib import Path
from typing import Dict, Any
import logging
try:
from .config.integrations import integration_config
except ImportError:
try:
from config.integrations import integration_config
except ImportError:
# Fallback for when running as standalone script
integration_config = None
logging.warning("Could not import integration_config - using defaults")
@click.group()
def cli():
"""Integration configuration management"""
pass
@cli.command()
def validate():
"""Validate current configuration"""
is_valid, issues = integration_config.validate()
if is_valid:
click.echo("✅ Configuration is valid!")
else:
click.echo("❌ Configuration issues found:")
for issue in issues:
click.echo(f" - {issue}")
@cli.command()
def show():
"""Show current configuration (without sensitive data)"""
config_dict = integration_config.to_dict()
click.echo("Current Configuration:")
click.echo(json.dumps(config_dict, indent=2))
@cli.command()
@click.argument('file_path')
def save(file_path):
"""Save configuration to file"""
if integration_config.save_to_file(file_path):
click.echo(f"✅ Configuration saved to {file_path}")
else:
click.echo("❌ Failed to save configuration")
@cli.command()
@click.argument('file_path')
def load(file_path):
"""Load configuration from file"""
if integration_config.load_from_file(file_path):
click.echo(f"✅ Configuration loaded from {file_path}")
else:
click.echo("❌ Failed to load configuration")
@cli.command()
def env():
"""Show environment variables for configuration"""
click.echo("Environment Variables for Configuration:")
click.echo("=" * 50)
env_vars = {
"SUPABASE_URL": "Supabase project URL",
"SUPABASE_KEY": "Supabase anon key",
"SUPABASE_SERVICE_KEY": "Supabase service role key",
"SUPABASE_DB_PASSWORD": "Database password",
"OPENAI_API_KEY": "OpenAI API key",
"ANTHROPIC_API_KEY": "Anthropic API key",
"GROQ_API_KEY": "Groq API key",
"LANGSMITH_TRACING": "Enable LangSmith tracing (true/false)",
"LANGSMITH_PROJECT": "LangSmith project name",
"LANGSMITH_API_KEY": "LangSmith API key",
"CREWAI_ENABLED": "Enable CrewAI (true/false)",
"CREWAI_MAX_AGENTS": "Maximum number of CrewAI agents",
"LLAMAINDEX_STORAGE_PATH": "LlamaIndex storage path",
"LLAMAINDEX_CHUNK_SIZE": "LlamaIndex chunk size",
"GAIA_TOOLS_ENABLED": "Enable GAIA tools (true/false)",
"GAIA_TIMEOUT": "GAIA timeout in seconds"
}
for var, description in env_vars.items():
value = "***" if "KEY" in var or "PASSWORD" in var else "not set"
click.echo(f"{var}: {description}")
click.echo(f" Current value: {value}")
click.echo()
@cli.command()
@click.option('--section', help='Configuration section to update')
@click.option('--key', help='Configuration key to update')
@click.option('--value', help='New value')
def update(section, key, value):
"""Update configuration values"""
if not all([section, key, value]):
click.echo("❌ Please provide section, key, and value")
return
updates = {section: {key: value}}
if integration_config.update_config(updates):
click.echo(f"✅ Updated {section}.{key} = {value}")
else:
click.echo("❌ Failed to update configuration")
@cli.command()
def test():
"""Test all integrations"""
click.echo("Testing integrations...")
# Test Supabase
if integration_config.supabase.is_configured():
click.echo("✅ Supabase configured")
else:
click.echo("⚠️ Supabase not configured")
# Test API keys
api_keys = {
"OpenAI": "OPENAI_API_KEY",
"Anthropic": "ANTHROPIC_API_KEY",
"Groq": "GROQ_API_KEY"
}
for name, env_var in api_keys.items():
if integration_config._load_from_environment.__globals__['os'].getenv(env_var):
click.echo(f"✅ {name} API key available")
else:
click.echo(f"⚠️ {name} API key not available")
# Validate config
is_valid, issues = integration_config.validate()
if is_valid:
click.echo("✅ Configuration validation passed")
else:
click.echo("❌ Configuration validation failed:")
for issue in issues:
click.echo(f" - {issue}")
if __name__ == "__main__":
cli() |