#!/usr/bin/env python3 """ Setup script for the AI Agent System for Port Recommendations Helps configure the environment and run the system. """ import os import subprocess import sys def check_dependencies(): """Check if required dependencies are installed""" print("šŸ” Checking dependencies...") required_packages = [ "gradio", "openai-agents", "faiss-cpu", "langchain", "langchain-community", "sentence-transformers", "PyYAML" ] missing_packages = [] for package in required_packages: try: __import__(package.replace("-", "_")) print(f"āœ… {package}") except ImportError: print(f"āŒ {package} (missing)") missing_packages.append(package) if missing_packages: print(f"\nšŸ“¦ Missing packages: {', '.join(missing_packages)}") print("Install with: pip install " + " ".join(missing_packages)) return False print("āœ… All dependencies installed!") return True def check_environment(): """Check environment configuration""" print("\nšŸ”§ Checking environment...") # Check for OpenAI API key if os.getenv("OPENAI_API_KEY"): print("āœ… OPENAI_API_KEY is set") api_key_status = True else: print("āŒ OPENAI_API_KEY is not set") print(" Set it with: export OPENAI_API_KEY='your-api-key-here'") api_key_status = False # Check for FAISS index if os.path.exists("faiss_index"): print("āœ… FAISS index exists") faiss_status = True else: print("āŒ FAISS index not found") print(" Run the loader script first to create the index") faiss_status = False return api_key_status and faiss_status def show_usage_examples(): """Show usage examples""" print("\nšŸ“– Usage Examples:") print("=" * 50) examples = [ { "query": "I need an unused port for a new server", "description": "Single port recommendation" }, { "query": "I need to dual connect a server to the network, what ports should I use?", "description": "MLAG dual connection recommendation" }, { "query": "What are the BGP settings for the fabric?", "description": "General network information query" }, { "query": "Show me available interfaces on switch01", "description": "Device-specific port query" } ] for i, example in enumerate(examples, 1): print(f"{i}. {example['description']}") print(f" Query: \"{example['query']}\"") print() def main(): """Main setup function""" print("šŸš€ AI Agent System Setup") print("=" * 50) deps_ok = check_dependencies() env_ok = check_environment() print("\nšŸ“Š Setup Summary:") print("=" * 30) if deps_ok and env_ok: print("āœ… System ready to run!") print("\nšŸŽÆ To start the system:") print(" python app.py") print("\n🌐 Web interface will be available at:") print(" http://127.0.0.1:7862") else: print("āš ļø Setup incomplete") if not deps_ok: print(" - Install missing dependencies") if not env_ok: print(" - Configure environment variables") print(" - Create FAISS index if needed") show_usage_examples() print("\nšŸ”— Additional Resources:") print("- README_AGENTS.md - Architecture documentation") print("- IMPLEMENTATION_SUMMARY.md - Implementation details") print("- validate_system.py - System validation tests") print("- demo.py - Interactive demonstration") if __name__ == "__main__": main()