vilarin commited on
Commit
0c20d85
1 Parent(s): fd6304d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -6
app.py CHANGED
@@ -69,7 +69,6 @@ def stream_chat(message: str, history: list, temperature: float, max_new_tokens:
69
 
70
  input_ids = tokenizer.apply_chat_template(conversation, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
71
 
72
- prompt_padded_len = len(input_ids[0])
73
 
74
  gen_tokens= model.generate(
75
  input_ids,
@@ -78,11 +77,7 @@ def stream_chat(message: str, history: list, temperature: float, max_new_tokens:
78
  temperature=temperature,
79
  )
80
 
81
- gen_tokens = [
82
- gt[prompt_padded_len:] for gt in gen_tokens
83
- ]
84
-
85
- gen_text = tokenizer.batch_decode(gen_tokens, skip_special_tokens=True)
86
 
87
  return gen_text
88
 
 
69
 
70
  input_ids = tokenizer.apply_chat_template(conversation, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
71
 
 
72
 
73
  gen_tokens= model.generate(
74
  input_ids,
 
77
  temperature=temperature,
78
  )
79
 
80
+ gen_text = tokenizer.decode(gen_tokens[0], skip_special_tokens=True)
 
 
 
 
81
 
82
  return gen_text
83