Spaces:
Sleeping
Sleeping
#!/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() | |