RasaBot / app.py
Luigi's picture
initial commit
59e8d1c
raw
history blame contribute delete
825 Bytes
import gradio as gr
import requests
RASA_URL = "http://localhost:5005/webhooks/rest/webhook"
def bot_response(user_message, chat_history):
resp = requests.post(RASA_URL, json={
"sender": "user",
"message": user_message
}).json()
bot_reply = resp[0].get("text") if resp else "🤖 (no reply)"
chat_history.append((user_message, bot_reply))
return chat_history
with gr.Blocks(title="Rasa 2.8.3 + Gradio v4 Demo") as demo:
chatbot = gr.Chatbot(label="Rasa Bot", height=400)
user_input = gr.Textbox(placeholder="Type here...", show_label=False)
user_input.submit(bot_response, inputs=[user_input, chatbot], outputs=chatbot)
gr.Button("Clear").click(lambda: [], None, chatbot)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)