Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,9 @@ def respond(
|
|
21 |
temperature,
|
22 |
top_p,
|
23 |
):
|
24 |
-
messages = [
|
|
|
|
|
25 |
|
26 |
for user, assistant in history:
|
27 |
if user:
|
@@ -33,7 +35,7 @@ def respond(
|
|
33 |
|
34 |
try:
|
35 |
stream = client.chat.completions.create(
|
36 |
-
model="Deepseek-R1-0528-Qwen3-8B",
|
37 |
messages=messages,
|
38 |
max_tokens=max_tokens,
|
39 |
temperature=temperature,
|
@@ -43,8 +45,7 @@ def respond(
|
|
43 |
|
44 |
output = ""
|
45 |
for chunk in stream:
|
46 |
-
|
47 |
-
delta = chunk.choices[0].delta.content or ""
|
48 |
output += delta
|
49 |
yield output
|
50 |
|
@@ -55,8 +56,8 @@ def respond(
|
|
55 |
demo = gr.ChatInterface(
|
56 |
respond,
|
57 |
additional_inputs=[
|
58 |
-
gr.Textbox(value="
|
59 |
-
gr.Slider(minimum=1, maximum=
|
60 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
61 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
62 |
],
|
|
|
21 |
temperature,
|
22 |
top_p,
|
23 |
):
|
24 |
+
messages = []
|
25 |
+
if system_message:
|
26 |
+
messages = [{"role": "system", "content": system_message}]
|
27 |
|
28 |
for user, assistant in history:
|
29 |
if user:
|
|
|
35 |
|
36 |
try:
|
37 |
stream = client.chat.completions.create(
|
38 |
+
model="Deepseek-R1-0528-Qwen3-8B",
|
39 |
messages=messages,
|
40 |
max_tokens=max_tokens,
|
41 |
temperature=temperature,
|
|
|
45 |
|
46 |
output = ""
|
47 |
for chunk in stream:
|
48 |
+
delta = chunk.choices[0].delta.content or chunk.choices[0].delta.reasoning_content or ""
|
|
|
49 |
output += delta
|
50 |
yield output
|
51 |
|
|
|
56 |
demo = gr.ChatInterface(
|
57 |
respond,
|
58 |
additional_inputs=[
|
59 |
+
gr.Textbox(value=".", label="System message"),
|
60 |
+
gr.Slider(minimum=1, maximum=8000, value=4096, step=1, label="Max new tokens"),
|
61 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
62 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
63 |
],
|