safwansajad commited on
Commit
99641c5
·
verified ·
1 Parent(s): 4e108a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -54,12 +54,16 @@ with gr.Blocks() as demo:
54
  outputs=[chatbot, emotion_out, score_out])
55
 
56
  # ------------------ API Endpoint for /api/predict ------------------
 
 
 
 
57
  predict_api = gr.Interface(
58
- fn=chatbot_response,
59
  inputs=[gr.Textbox(label="Message"), gr.Textbox(label="Session ID")],
60
  outputs=[gr.Textbox(label="Response"), gr.Textbox(label="Emotion"), gr.Number(label="Score")]
61
  )
62
 
63
  # ------------------ Launch for Gradio Spaces ------------------
64
- demo.launch()
65
  predict_api.launch(inline=False)
 
54
  outputs=[chatbot, emotion_out, score_out])
55
 
56
  # ------------------ API Endpoint for /api/predict ------------------
57
+ def api_predict(message, session_id="default"):
58
+ response, emotion, score = chatbot_response(message, session_id)
59
+ return {"response": response, "emotion": emotion, "score": score}
60
+
61
  predict_api = gr.Interface(
62
+ fn=api_predict,
63
  inputs=[gr.Textbox(label="Message"), gr.Textbox(label="Session ID")],
64
  outputs=[gr.Textbox(label="Response"), gr.Textbox(label="Emotion"), gr.Number(label="Score")]
65
  )
66
 
67
  # ------------------ Launch for Gradio Spaces ------------------
68
+ demo.launch(share=True)
69
  predict_api.launch(inline=False)