llm-api-free / app.py
Bc-AI's picture
Upload 3 files
cfc79aa verified
import os
import subprocess
import sys
from pathlib import Path
# Main entry point for the multi-node Hugging Face API system
# This can be used to start either the head node or a worker node based on environment
def main():
node_type = os.getenv("NODE_TYPE", "head") # Default to head node
if node_type == "head":
print("πŸš€ Starting Head Node API Gateway...")
from head_node.app import app
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
elif node_type in ["nano", "mini", "fast", "large"]:
print(f"πŸš€ Starting Worker Node for {node_type} model...")
from worker_nodes.worker_app import app
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 8000)))
else:
print(f"Unknown node type: {node_type}")
print("Use NODE_TYPE=head for head node, or NODE_TYPE=[nano|mini|fast|large] for workers")
sys.exit(1)
if __name__ == "__main__":
main()