CoolFace
Apppublic

hina625/agent-Backend

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
hf_wrapper.py28 linesDownload Raw Back to root
1import os2import subprocess3import threading4from flask import Flask5 6app = Flask(__name__)7 8@app.route('/')9def home():10    return "Astra AI Agent is running successfully!"11 12def run_agent():13    print("Starting Astra Agent in background...")14    # Run the livekit agent15    subprocess.run(["python", "agent.py", "start"])16 17if __name__ == '__main__':18    # Start the agent in a separate thread so it doesn't block the web server19    agent_thread = threading.Thread(target=run_agent)20    agent_thread.daemon = True21    agent_thread.start()22 23    # Hugging Face Spaces requires a web server to bind to port 786024    # Otherwise it marks the deployment as "failed"25    port = int(os.environ.get("PORT", 7860))26    print(f"Starting dummy web server on port {port} to satisfy HuggingFace health checks...")27    app.run(host='0.0.0.0', port=port)28