helloperson123 commited on
Commit
220a3ff
·
verified ·
1 Parent(s): 238b386

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -50,8 +50,17 @@ def ask():
50
  )
51
 
52
 
53
- text = tokenizer.decode(outputs[0], skip_special_tokens=True)
54
- reply = text.split("Assistant:")[-1].strip()
 
 
 
 
 
 
 
 
 
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