Spaces:
Paused
Paused
smileycutie0 commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,4 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from huggingface_hub import InferenceClient
|
| 4 |
-
|
| 5 |
-
SYSTEM_PROMPT = os.environ["SYSTEM_PROMPT"]
|
| 6 |
-
client = InferenceClient("HuggingFaceTB/SmolLM2-1.7B-Instruct")
|
| 7 |
-
|
| 8 |
-
def chat(message, history):
|
| 9 |
-
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 10 |
-
messages.extend(history)
|
| 11 |
-
messages.append({"role": "user", "content": message})
|
| 12 |
-
|
| 13 |
-
result = ""
|
| 14 |
-
for chunk in client.chat.completions.create(
|
| 15 |
-
messages,
|
| 16 |
-
max_tokens=1024,
|
| 17 |
-
stream=True
|
| 18 |
-
):
|
| 19 |
-
result += chunk.choices[0].delta.content
|
| 20 |
-
yield result
|
| 21 |
|
| 22 |
with gr.Blocks(
|
| 23 |
title="💬 SmolLM Instruct",
|
|
@@ -29,12 +10,7 @@ with gr.Blocks(
|
|
| 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):
|
| 39 |
gr.Markdown(f"""
|
| 40 |
* Created by [🍒 cherry-ghosts community](https://hf.co/cherry-ghosts)
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
with gr.Blocks(
|
| 4 |
title="💬 SmolLM Instruct",
|
|
|
|
| 10 |
)
|
| 11 |
) as app:
|
| 12 |
gr.Markdown("# 💬 SmolLM Instruct")
|
| 13 |
+
gr.load("models/HuggingFaceTB/SmolLM2-1.7B-Instruct")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
with gr.Accordion("ℹ️ About", open=False):
|
| 15 |
gr.Markdown(f"""
|
| 16 |
* Created by [🍒 cherry-ghosts community](https://hf.co/cherry-ghosts)
|