Mohd-Shujath commited on
Commit
fb2297e
·
1 Parent(s): 2419d6a

Use uvicorn with environment PORT

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -110,7 +110,7 @@ def chat_endpoint(payload: ChatRequest, x_api_key: Optional[str] = Header(None))
110
  }
111
 
112
  # =============================================================
113
- # 4. Gradio Chat UI mounted at /ui (avoiding root conflict)
114
  # =============================================================
115
  def gradio_chat(user_message, history):
116
  hist_formatted = []
@@ -127,11 +127,13 @@ demo = gr.ChatInterface(
127
  description="Fine-tuned Qwen 0.8B Q4_K_M — llama-cpp-python inference"
128
  )
129
 
130
- # Mount Gradio UI cleanly without hijacking API endpoints
131
  app = gr.mount_gradio_app(app, demo, path="/")
132
 
133
  # =============================================================
134
- # 5. Native Launch using demo.launch(app=...)
135
  # =============================================================
136
  if __name__ == "__main__":
137
- demo.launch(app=app)
 
 
 
110
  }
111
 
112
  # =============================================================
113
+ # 4. Gradio Chat UI
114
  # =============================================================
115
  def gradio_chat(user_message, history):
116
  hist_formatted = []
 
127
  description="Fine-tuned Qwen 0.8B Q4_K_M — llama-cpp-python inference"
128
  )
129
 
130
+ # Mount Gradio UI on the FastAPI app
131
  app = gr.mount_gradio_app(app, demo, path="/")
132
 
133
  # =============================================================
134
+ # 5. Uvicorn Runner on Environment PORT
135
  # =============================================================
136
  if __name__ == "__main__":
137
+ import uvicorn
138
+ port = int(os.environ.get("PORT", 7860))
139
+ uvicorn.run(app, host="0.0.0.0", port=port)