Spaces:
Paused
Paused
smileycutie0 commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,12 +6,13 @@ SYSTEM_PROMPT = os.environ["SYSTEM_PROMPT"]
|
|
| 6 |
client = InferenceClient("HuggingFaceTB/SmolLM2-1.7B-Instruct")
|
| 7 |
|
| 8 |
def chat(message, history):
|
| 9 |
-
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
result = ""
|
| 13 |
for chunk in client.chat.completions.create(
|
| 14 |
-
messages=
|
| 15 |
max_tokens=1024,
|
| 16 |
stream=True
|
| 17 |
):
|
|
@@ -19,7 +20,7 @@ def chat(message, history):
|
|
| 19 |
yield result
|
| 20 |
|
| 21 |
with gr.Blocks(
|
| 22 |
-
title="
|
| 23 |
css="footer {display: none !important}",
|
| 24 |
theme=gr.themes.Base(
|
| 25 |
primary_hue="red",
|
|
@@ -27,12 +28,11 @@ with gr.Blocks(
|
|
| 27 |
neutral_hue="neutral"
|
| 28 |
)
|
| 29 |
) as app:
|
| 30 |
-
gr.Markdown("#
|
| 31 |
|
| 32 |
gr.ChatInterface(
|
| 33 |
fn=chat,
|
| 34 |
-
type="messages"
|
| 35 |
-
examples=["Hi!", "Who are you?"]
|
| 36 |
)
|
| 37 |
|
| 38 |
with gr.Accordion("ℹ️ About", open=False):
|
|
|
|
| 6 |
client = InferenceClient("HuggingFaceTB/SmolLM2-1.7B-Instruct")
|
| 7 |
|
| 8 |
def chat(message, history):
|
| 9 |
+
msg = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 10 |
+
msg.extend(history)
|
| 11 |
+
msg.append({"role": "user", "content": message})
|
| 12 |
|
| 13 |
result = ""
|
| 14 |
for chunk in client.chat.completions.create(
|
| 15 |
+
messages=msg,
|
| 16 |
max_tokens=1024,
|
| 17 |
stream=True
|
| 18 |
):
|
|
|
|
| 20 |
yield result
|
| 21 |
|
| 22 |
with gr.Blocks(
|
| 23 |
+
title="💬 SmolLM Instruct",
|
| 24 |
css="footer {display: none !important}",
|
| 25 |
theme=gr.themes.Base(
|
| 26 |
primary_hue="red",
|
|
|
|
| 28 |
neutral_hue="neutral"
|
| 29 |
)
|
| 30 |
) as app:
|
| 31 |
+
gr.Markdown("# 💬 SmolLM Instruct")
|
| 32 |
|
| 33 |
gr.ChatInterface(
|
| 34 |
fn=chat,
|
| 35 |
+
type="messages"
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
with gr.Accordion("ℹ️ About", open=False):
|