File size: 1,016 Bytes
eff99d8 ae152d5 aa36139 eff99d8 77b14f6 aa36139 77b14f6 aa36139 ae152d5 aa36139 77b14f6 aa36139 77b14f6 eff99d8 aa36139 |
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 |
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)
|