rkoushikroy2's picture
Upload app.py
5f1eb7f
raw
history blame
1.44 kB
# Imports
import gradio as gr
from helper_functions import *
with gr.Blocks() as app:
gr.Markdown('# FundedNext Customer Service Chatbot')
with gr.Tab("Chat"):
with gr.Row():
with gr.Column():
msg = gr.Textbox()
with gr.Row():
submit = gr.Button("Submit")
clear = gr.Button("Clear")
with gr.Column():
chatbot = gr.Chatbot()
def user(user_message, history):
return "", history + [[user_message, None]]
def bot(history):
bot_message = get_reply(history[-1][0])
history[-1][1] = bot_message
return history
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
).then(
fn = reset_memory, inputs = None, outputs = None
)
submit.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
)
clear.click(fn = lambda: None, inputs = None, outputs = chatbot, queue=False).then(
fn = clear_variables, inputs = None, outputs = None, queue=False
)
with gr.Tab("Prompt"):
context = gr.Textbox()
submit = gr.Button("Check Prompt")
submit.click(get_context_gr, None, context, queue=False)
app.launch()