Spaces:
Paused
Paused
clear hist
Browse files
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 |
|