Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,10 +37,11 @@ def generate(message: str,
|
|
37 |
do_sample: bool = False,
|
38 |
) -> Iterator[str]:
|
39 |
stop_event.clear()
|
|
|
40 |
|
41 |
# Prepare input for the model
|
42 |
conversation = [
|
43 |
-
{"role": "user", "content": f"Please translate the following into English: {message
|
44 |
]
|
45 |
input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt")
|
46 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
|
|
37 |
do_sample: bool = False,
|
38 |
) -> Iterator[str]:
|
39 |
stop_event.clear()
|
40 |
+
message=message.replace('\n',' ')
|
41 |
|
42 |
# Prepare input for the model
|
43 |
conversation = [
|
44 |
+
{"role": "user", "content": f"Please translate the following into English: {message} Translation:"}
|
45 |
]
|
46 |
input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt")
|
47 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|