safwansajad commited on
Commit
f0c943d
·
verified ·
1 Parent(s): 0611b6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -53,10 +53,13 @@ with gr.Blocks() as demo:
53
  inputs=[session_id],
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
- # ------------------ Launch for Gradio Spaces ------------------
62
- demo.launch(share=True, server_name="0.0.0.0", server_port=7860)
 
 
53
  inputs=[session_id],
54
  outputs=[chatbot, emotion_out, score_out])
55
 
56
+ # ------------------ API Endpoint ------------------
57
+ api_interface = gr.Interface(
58
+ fn=chatbot_response, # Exposing the chatbot function
59
+ inputs=[gr.Textbox(label="Message"), gr.Textbox(label="Session ID", value="default")],
60
+ outputs=[gr.Textbox(label="Chatbot Response"), gr.Textbox(label="Detected Emotion"), gr.Number(label="Confidence Score")]
61
+ )
62
 
63
+ # Launch Gradio interface and API
64
+ demo.launch(share=True, server_name="0.0.0.0", server_port=7860)
65
+ api_interface.launch(share=True, server_name="0.0.0.0", server_port=7861)