Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -51,8 +51,19 @@ def respond(message, history):
|
|
| 51 |
repetition_penalty=1.1,
|
| 52 |
)
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
demo = gr.ChatInterface(
|
| 58 |
fn=respond,
|
|
|
|
| 51 |
repetition_penalty=1.1,
|
| 52 |
)
|
| 53 |
|
| 54 |
+
raw = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)
|
| 55 |
+
|
| 56 |
+
# Strip Llama 3 structured output format if present
|
| 57 |
+
if isinstance(raw, str) and raw.startswith("[{"):
|
| 58 |
+
try:
|
| 59 |
+
import json
|
| 60 |
+
parsed = json.loads(raw)
|
| 61 |
+
if isinstance(parsed, list):
|
| 62 |
+
raw = " ".join(item.get("text", "") for item in parsed if isinstance(item, dict))
|
| 63 |
+
except (json.JSONDecodeError, TypeError):
|
| 64 |
+
pass
|
| 65 |
+
|
| 66 |
+
return raw.strip()
|
| 67 |
|
| 68 |
demo = gr.ChatInterface(
|
| 69 |
fn=respond,
|