File size: 517 Bytes
f6a74b6
 
9080fc6
ec8aef1
 
be308f2
60c1a90
 
be308f2
ec8aef1
 
60c1a90
 
be308f2
60c1a90
be308f2
60c1a90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18



import gradio as gr
import requests

# Change RASA_URL to the local server
RASA_URL = "http://localhost:5005/webhooks/rest/webhook"

def chat_with_bot(user_message):
    response = requests.post(RASA_URL, json={"sender": "user", "message": user_message})
    bot_reply = response.json()[0]["text"] if response.json() else "I didn't understand that."
    return bot_reply

iface = gr.Interface(fn=chat_with_bot, inputs="text", outputs="text", title="Chatbot")

iface.launch(server_name="0.0.0.0", server_port=7860)