Spaces:
Sleeping
Sleeping
File size: 3,871 Bytes
890d952 |
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 |
#!/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()
|