BasilTh
commited on
Commit
Β·
aa36139
1
Parent(s):
f194ae0
Deploy updated SLM customer-support chatbot
Browse files- README.md +9 -9
- app.py +19 -11
- requirements.txt +4 -4
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
|
|
|
|
4 |
sdk: gradio
|
5 |
-
sdk_version: 5.41.1
|
6 |
app_file: app.py
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
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 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
# Gradio chat UI
|
7 |
def respond(user_message, history):
|
8 |
-
|
9 |
-
|
10 |
-
return history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
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
|
|
|
|
|
|