agAdvisor / run_api.py
tirtho149's picture
Deploy AgAdvisor
b30f068 verified
Raw
History Blame Contribute Delete
2.51 kB
#!/usr/bin/env python3
"""
Simple script to run the Agentic AI API server without Docker.
Just run: python run_api.py
"""
import sys
import os
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / "src"))
def check_dependencies():
"""Check if we have the required packages."""
missing = []
try:
import fastapi
print("βœ… FastAPI available")
except ImportError:
missing.append("fastapi")
try:
import uvicorn
print("βœ… Uvicorn available")
except ImportError:
missing.append("uvicorn")
try:
import spacy
nlp = spacy.load("en_core_web_sm")
print("βœ… spaCy model available")
except (ImportError, OSError):
missing.append("spacy model")
if missing:
print(f"\\n❌ Missing: {', '.join(missing)}")
print("\\nπŸ“¦ Install missing packages:")
if "fastapi" in missing or "uvicorn" in missing:
print(" pip install fastapi uvicorn python-multipart")
if "spacy model" in missing:
print(" python -m spacy download en_core_web_sm")
return False
return True
def main():
"""Run the API server."""
print("πŸ€– Agentic AI System - Simple API Server")
print("=" * 50)
# Check dependencies
if not check_dependencies():
print("\\nπŸ’‘ Install dependencies first, then run again.")
return
print("\\nπŸš€ Starting API server...")
print("πŸ“ Server: http://localhost:8000")
print("πŸ“š Docs: http://localhost:8000/docs")
print("❀️ Health: http://localhost:8000/health")
print("\\nπŸ”‘ API Keys for testing:")
print(" Demo: demo-key-12345")
print(" Admin: admin-key-67890")
print("\\nπŸ“ API Key Configuration:")
print(" πŸ“„ Primary: config/api_keys.json")
print(" πŸ”„ Fallback: api_server.py")
print(" πŸ”§ Reload: POST /api-keys/reload (admin only)")
print("\\n" + "=" * 50)
# Import and run
try:
import uvicorn
from api_server import app
uvicorn.run(
app,
host="0.0.0.0",
port=8000,
log_level="info"
)
except KeyboardInterrupt:
print("\\nπŸ›‘ Server stopped")
except Exception as e:
print(f"\\n❌ Error: {e}")
if __name__ == "__main__":
main()