File size: 2,508 Bytes
b30f068 | 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 | #!/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()
|