Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,8 +50,17 @@ def ask():
|
|
| 50 |
)
|
| 51 |
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
return jsonify({"reply": reply})
|
| 57 |
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
|
| 53 |
+
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 54 |
+
|
| 55 |
+
reply = decoded.split("Response:", 1)[-1]
|
| 56 |
+
|
| 57 |
+
STOP_WORDS = ["User:", "AI:", "Assistant:", "Question:", "Answer:"]
|
| 58 |
+
for s in STOP_WORDS:
|
| 59 |
+
if s in reply:
|
| 60 |
+
reply = reply.split(s)[0]
|
| 61 |
+
|
| 62 |
+
reply = reply.strip()
|
| 63 |
+
|
| 64 |
|
| 65 |
return jsonify({"reply": reply})
|
| 66 |
|