|
|
""" |
|
|
Main application file for ComputeAgent on HuggingFace Spaces. |
|
|
Integrates FastAPI backend with Gradio frontend interface. |
|
|
""" |
|
|
|
|
|
import os |
|
|
import sys |
|
|
import logging |
|
|
import uvicorn |
|
|
import gradio as gr |
|
|
|
|
|
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__)) |
|
|
sys.path.insert(0, current_dir) |
|
|
|
|
|
|
|
|
logging.basicConfig( |
|
|
level=logging.INFO, |
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' |
|
|
) |
|
|
logger = logging.getLogger("ComputeAgent-HF") |
|
|
|
|
|
|
|
|
from ComputeAgent.main import app as fastapi_app |
|
|
|
|
|
|
|
|
from Gradio_interface import create_gradio_demo |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
logger.info("=" * 80) |
|
|
logger.info("π€ ComputeAgent - HuggingFace Spaces Deployment") |
|
|
logger.info("=" * 80) |
|
|
|
|
|
|
|
|
|
|
|
demo = create_gradio_demo(api_base_url="http://localhost:7860") |
|
|
|
|
|
|
|
|
|
|
|
app = gr.mount_gradio_app(fastapi_app, demo, path="/") |
|
|
|
|
|
logger.info("β
Combined FastAPI + Gradio app ready") |
|
|
logger.info("π Server starting on port 7860") |
|
|
logger.info("=" * 80) |
|
|
|
|
|
|
|
|
uvicorn.run( |
|
|
app, |
|
|
host="0.0.0.0", |
|
|
port=7860, |
|
|
log_level="info" |
|
|
) |
|
|
|