Spaces:
Build error
Build error
Update app.py
Browse filesAdded a sanitization for the <think> tags
app.py
CHANGED
@@ -62,6 +62,12 @@ def chat_fn(history, enable_thinking, temperature, top_p, top_k, repetition_pena
|
|
62 |
)
|
63 |
output_ids = streamer[0][len(inputs.input_ids[0]):]
|
64 |
response = tokenizer.decode(output_ids, skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
# streaming char-by-char
|
67 |
history.append({"role": "assistant", "content": ""})
|
|
|
62 |
)
|
63 |
output_ids = streamer[0][len(inputs.input_ids[0]):]
|
64 |
response = tokenizer.decode(output_ids, skip_special_tokens=True)
|
65 |
+
if isinstance(response, str):
|
66 |
+
response = response.replace('<think>',"# <think>").replace('</think>',"</think>")
|
67 |
+
elif isinstance(response,list):
|
68 |
+
response = [paper.replace('<think>',"# <think>").replace('</think>',"</think>") for paper in response]
|
69 |
+
else:
|
70 |
+
raise ValueError("Tokenizer response seems malformed; Not a string, nor a list?!?!")
|
71 |
|
72 |
# streaming char-by-char
|
73 |
history.append({"role": "assistant", "content": ""})
|