Spaces:
Build error
Build error
File size: 1,443 Bytes
8e66315 5f1eb7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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()
|