Trigger82 commited on
Commit
642d8b4
·
verified ·
1 Parent(s): af440aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -10,6 +10,10 @@ model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
10
 
11
  chat_history = {}
12
 
 
 
 
 
13
  @app.get("/ai")
14
  async def chat(request: Request):
15
  query_params = dict(request.query_params)
@@ -24,9 +28,4 @@ async def chat(request: Request):
24
  response = tokenizer.decode(output_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
25
 
26
  chat_history[user_id] = [bot_input_ids, output_ids]
27
- return JSONResponse({"reply": response})
28
-
29
- # ✅ Add this to launch properly on Hugging Face Spaces
30
- if __name__ == "__main__":
31
- import uvicorn
32
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
10
 
11
  chat_history = {}
12
 
13
+ @app.get("/")
14
+ async def root():
15
+ return {"message": "🟢 API is live! Use `/ai?query=Hello&user_id=123`"}
16
+
17
  @app.get("/ai")
18
  async def chat(request: Request):
19
  query_params = dict(request.query_params)
 
28
  response = tokenizer.decode(output_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
29
 
30
  chat_history[user_id] = [bot_input_ids, output_ids]
31
+ return JSONResponse({"reply": response})