braindeck commited on
Commit
bf33a33
·
1 Parent(s): fb0bb52

Remove think block from response

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -18,6 +18,11 @@ def generate_response(prompt):
18
 
19
  # Decode the generated text
20
  generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
 
21
 
22
  return generated_text
23
 
@@ -42,4 +47,4 @@ with gr.Blocks() as demo:
42
  )
43
 
44
  if __name__ == "__main__":
45
- demo.launch()
 
18
 
19
  # Decode the generated text
20
  generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
21
+
22
+ # Remove the think block
23
+ ix = generated_text.find("</think>")
24
+ if ix != -1:
25
+ generated_text = generated_text[ix + len("</think>") :].lstrip()
26
 
27
  return generated_text
28
 
 
47
  )
48
 
49
  if __name__ == "__main__":
50
+ demo.launch()