codys12 commited on
Commit
73d0fad
1 Parent(s): dac8084

clear hist

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -47,6 +47,8 @@ def generate(
47
 
48
  device = "cuda"
49
  input_ids = tokenizer(current_input, return_tensors="pt").input_ids.to(device)
 
 
50
 
51
  if len(input_ids) > MAX_INPUT_TOKEN_LENGTH:
52
  input_ids = input_ids[-MAX_INPUT_TOKEN_LENGTH:]
@@ -70,7 +72,7 @@ def generate(
70
 
71
  outputs = []
72
  for text in streamer:
73
- print(text, end="")
74
  outputs.append(text)
75
  yield "".join(outputs)
76
 
 
47
 
48
  device = "cuda"
49
  input_ids = tokenizer(current_input, return_tensors="pt").input_ids.to(device)
50
+ original_input_length = input_ids.shape[1] # Remember the input length
51
+
52
 
53
  if len(input_ids) > MAX_INPUT_TOKEN_LENGTH:
54
  input_ids = input_ids[-MAX_INPUT_TOKEN_LENGTH:]
 
72
 
73
  outputs = []
74
  for text in streamer:
75
+ print(text.replace(history, ""), end="")
76
  outputs.append(text)
77
  yield "".join(outputs)
78