Spaces:
Running
Running
File size: 1,263 Bytes
76db545 | 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 | """
Phase 4b: Start the FastAPI inference server.
Usage:
python scripts/run_server.py
python scripts/run_server.py --host 0.0.0.0 --port 8000
"""
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from dotenv import load_dotenv
load_dotenv()
import uvicorn
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Start Sahel-Agri Voice AI server")
parser.add_argument("--host", default="0.0.0.0")
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--reload", action="store_true", help="Enable hot-reload (dev only)")
args = parser.parse_args()
print(f"Starting server on http://{args.host}:{args.port}")
print("Endpoints:")
print(f" GET http://localhost:{args.port}/api/v1/health")
print(f" POST http://localhost:{args.port}/api/v1/transcribe")
print(f" POST http://localhost:{args.port}/api/v1/query")
print(f" GET http://localhost:{args.port}/docs (Swagger UI)")
print()
uvicorn.run(
"src.api.app:app",
host=args.host,
port=args.port,
workers=1, # Single worker: GPU model shared in memory
reload=args.reload,
log_level="info",
)
|