BasilTh commited on
Commit
aa36139
Β·
1 Parent(s): f194ae0

Deploy updated SLM customer-support chatbot

Browse files
Files changed (3) hide show
  1. README.md +9 -9
  2. app.py +19 -11
  3. requirements.txt +4 -4
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
- license: mit
3
- title: Customer Support Chatbot
 
 
4
  sdk: gradio
5
- sdk_version: 5.41.1
6
  app_file: app.py
7
- emoji: πŸš€
8
- colorFrom: blue
9
- colorTo: purple
10
- pinned: false
11
- short_description: A lightweight QLoRA‐powered support assistant with memory
12
- ---
 
1
  ---
2
+ title: "Customer Support Chatbot"
3
+ emoji: "πŸ›Ž"
4
+ colorFrom: "blue"
5
+ colorTo: "purple"
6
  sdk: gradio
7
+ sdk_version: "5.41.1" # Must be quoted and match your requirements :contentReference[oaicite:11]{index=11}
8
  app_file: app.py
9
+ ---
10
+ <!-- Your app description below -->
11
+ This Space hosts a customer-support chatbot powered by an Unsloth-QLoRA SLM with conversational memory.
12
+ --
 
 
app.py CHANGED
@@ -1,16 +1,24 @@
1
- # ─── app.py ─────────────────────────────────────────────────────────────────
2
  import os
3
- from gradio import ChatInterface, FileMessage, TextMessage
4
- from SLM_CService import chat_with_memory, conversation_history
 
 
5
 
6
- # Gradio chat UI
7
  def respond(user_message, history):
8
- reply = chat_with_memory(user_message)
9
- # Gradio expects list of lists
10
- return history + [(user_message, reply)]
 
 
 
 
 
 
 
 
 
 
11
 
12
- iface = ChatInterface(fn=respond,
13
- title="SLM Customer Support Bot",
14
- description="A quantized TinyLlama+QLoRA chatbot with simple memory.")
15
- iface.launch()
16
 
 
 
1
  import os
2
+ os.environ["OMP_NUM_THREADS"] = "1" # Silence Gradio startup warning
3
+
4
+ import gradio as gr
5
+ from SLM_CService import chat_with_memory
6
 
 
7
  def respond(user_message, history):
8
+ bot_reply = chat_with_memory(user_message)
9
+ history = history + [(user_message, bot_reply)]
10
+ return history, history
11
+
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("# πŸ›Ž Customer Support Chatbot")
14
+ chatbot = gr.Chatbot() # Replaces ChatInterface/FileMessage/TextMessage :contentReference[oaicite:8]{index=8}
15
+ with gr.Row():
16
+ user_in = gr.Textbox(placeholder="Type your message here...")
17
+ submit = gr.Button("Send")
18
+ reset = gr.Button("πŸ”„ Reset Chat")
19
+ submit.click(respond, [user_in, chatbot], [chatbot, chatbot])
20
+ reset.click(lambda: ([], []), None, [chatbot, chatbot])
21
 
22
+ if __name__ == "__main__":
23
+ demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
24
 
requirements.txt CHANGED
@@ -1,11 +1,11 @@
1
- gradio
2
  transformers
 
 
 
3
  bitsandbytes
4
  peft
5
  xformers
6
  unsloth
7
  unsloth_zoo
8
  huggingface_hub
9
- sentencepiece
10
- torch
11
- langchain
 
1
+ gradio==5.41.1 # Matches Spaces SDK version :contentReference[oaicite:9]{index=9}
2
  transformers
3
+ torch
4
+ sentencepiece
5
+ langchain # Required for ConversationBufferMemory :contentReference[oaicite:10]{index=10}
6
  bitsandbytes
7
  peft
8
  xformers
9
  unsloth
10
  unsloth_zoo
11
  huggingface_hub