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()