chat-with-avd-doc / setup.py
rogerscuall's picture
Upload folder using huggingface_hub
890d952 verified
#!/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()