manasagangotri commited on
Commit
60c1a90
·
verified ·
1 Parent(s): 4952a5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -4,19 +4,14 @@
4
  import gradio as gr
5
  import requests
6
 
7
- RASA_URL = "http://0.0.0.0:5002/api"
8
-
9
-
10
-
11
 
12
  def chat_with_bot(user_message):
13
  response = requests.post(RASA_URL, json={"sender": "user", "message": user_message})
14
- bot_reply = response.json()
15
- if bot_reply:
16
- return bot_reply[0]['text']
17
- return "I didn't understand that."
18
 
19
- # Gradio UI
20
- iface = gr.Interface(fn=chat_with_bot, inputs="text", outputs="text", title="Chat with Rasa Bot")
21
- iface.launch(server_name="0.0.0.0", server_port=7860)
22
 
 
 
4
  import gradio as gr
5
  import requests
6
 
7
+ # Change RASA_URL to the local server
8
+ RASA_URL = "http://localhost:5005/webhooks/rest/webhook"
 
 
9
 
10
  def chat_with_bot(user_message):
11
  response = requests.post(RASA_URL, json={"sender": "user", "message": user_message})
12
+ bot_reply = response.json()[0]["text"] if response.json() else "I didn't understand that."
13
+ return bot_reply
 
 
14
 
15
+ iface = gr.Interface(fn=chat_with_bot, inputs="text", outputs="text", title="Chatbot")
 
 
16
 
17
+ iface.launch(server_name="0.0.0.0", server_port=7860)