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