Hermes SIQ-1-35B on ZeroGPU (llama-cpp-python recipe)
Browse files
app.py
CHANGED
|
@@ -141,16 +141,24 @@ def _artifact_name(head):
|
|
| 141 |
|
| 142 |
|
| 143 |
def _split(text):
|
| 144 |
-
"""Return (clean_answer, thinking).
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
i = text.index("<think>")
|
| 149 |
-
think_parts.append(text[i + len("<think>"):])
|
| 150 |
answer = text[:i]
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
| 154 |
return answer.strip(), thinking
|
| 155 |
|
| 156 |
|
|
@@ -985,13 +993,13 @@ EXAMPLES = [
|
|
| 985 |
"Explain a black hole like we are old friends.",
|
| 986 |
]
|
| 987 |
|
| 988 |
-
with gr.Blocks(title="Hermes · SIQ-1-35B", fill_height=True) as demo:
|
| 989 |
gr.HTML(HERO)
|
| 990 |
meta_state = gr.State([])
|
| 991 |
with gr.Row(equal_height=False):
|
| 992 |
with gr.Column(scale=5):
|
| 993 |
chatbot = gr.Chatbot(
|
| 994 |
-
height=460, show_label=False,
|
| 995 |
placeholder="Ask Hermes to build something or look something up.",
|
| 996 |
)
|
| 997 |
msg = gr.Textbox(
|
|
|
|
| 141 |
|
| 142 |
|
| 143 |
def _split(text):
|
| 144 |
+
"""Return (clean_answer, thinking). Robust to the common Qwen-thinking case
|
| 145 |
+
where the chat template injects the opening <think> so the model only emits
|
| 146 |
+
the CLOSING </think> (no opening tag in the stream)."""
|
| 147 |
+
text = text or ""
|
| 148 |
+
if "</think>" in text:
|
| 149 |
+
# everything up to the first </think> is reasoning, even with no <think>
|
| 150 |
+
i = text.index("</think>")
|
| 151 |
+
thinking = text[:i].replace("<think>", "").strip()
|
| 152 |
+
answer = text[i + len("</think>"):]
|
| 153 |
+
elif "<think>" in text:
|
| 154 |
+
# opening tag present but not yet closed -> still thinking, no answer
|
| 155 |
i = text.index("<think>")
|
|
|
|
| 156 |
answer = text[:i]
|
| 157 |
+
thinking = text[i + len("<think>"):].strip()
|
| 158 |
+
else:
|
| 159 |
+
answer, thinking = text, ""
|
| 160 |
+
answer = _TOOL_BLOCK.sub("", answer) # hide tool-call JSON
|
| 161 |
+
answer = answer.replace("<think>", "").replace("</think>", "") # stray tags
|
| 162 |
return answer.strip(), thinking
|
| 163 |
|
| 164 |
|
|
|
|
| 993 |
"Explain a black hole like we are old friends.",
|
| 994 |
]
|
| 995 |
|
| 996 |
+
with gr.Blocks(title="Hermes · SIQ-1-35B", fill_height=True, fill_width=True) as demo:
|
| 997 |
gr.HTML(HERO)
|
| 998 |
meta_state = gr.State([])
|
| 999 |
with gr.Row(equal_height=False):
|
| 1000 |
with gr.Column(scale=5):
|
| 1001 |
chatbot = gr.Chatbot(
|
| 1002 |
+
height=460, show_label=False, sanitize_html=False,
|
| 1003 |
placeholder="Ask Hermes to build something or look something up.",
|
| 1004 |
)
|
| 1005 |
msg = gr.Textbox(
|