BasilTh
Deploy updated SLM customer-support chatbot
77b14f6
raw
history blame
977 Bytes
import os
os.environ["OMP_NUM_THREADS"] = "1" # silence OpenMP spam
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()
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])
# Optional: submit on enter
user_in.submit(respond, [user_in, chatbot], [chatbot, chatbot])
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)