BasilTh
Deploy updated SLM customer-support chatbot
ae152d5
raw
history blame
1.02 kB
import os
os.environ["OMP_NUM_THREADS"] = "1"
import gradio as gr
from SLM_CService import chat_with_memory
def respond(user_message, history):
if not user_message:
return history, history
bot_reply = chat_with_memory(user_message)
history = (history or []) + [(user_message, bot_reply)]
return history, history
with gr.Blocks() as demo:
gr.Markdown("# πŸ›Ž Customer Support Chatbot")
chatbot = gr.Chatbot(type="tuples") # explicitly pick format; see Gradio docs. :contentReference[oaicite:5]{index=5}
with gr.Row():
user_in = gr.Textbox(placeholder="Type your message here...", scale=5)
send = gr.Button("Send", variant="primary")
reset = gr.Button("πŸ”„ Reset Chat")
send.click(respond, [user_in, chatbot], [chatbot, chatbot])
reset.click(lambda: ([], []), None, [chatbot, chatbot])
user_in.submit(respond, [user_in, chatbot], [chatbot, chatbot])
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)