Spaces:
Sleeping
Sleeping
[email protected]
commited on
Commit
·
75466a3
1
Parent(s):
bb351ec
put timeout as a parameter
Browse files
app.py
CHANGED
@@ -21,6 +21,9 @@ from peft import AutoPeftModelForCausalLM
|
|
21 |
import torch
|
22 |
import os
|
23 |
|
|
|
|
|
|
|
24 |
if os.environ.get("HF_TOKEN") is None:
|
25 |
raise ValueError(
|
26 |
"You must set the HF_TOKEN environment variable to use this script, you also need to have access to the Llama 3.2 model family"
|
@@ -119,7 +122,7 @@ def infere(
|
|
119 |
# Start generation on a separate thread, so that we don't block the UI. The text is pulled from the streamer
|
120 |
# in the main thread. Adds timeout to the streamer to handle exceptions in the generation thread.
|
121 |
streamer = TextIteratorStreamer(
|
122 |
-
tokenizer, timeout=
|
123 |
)
|
124 |
generate_kwargs = dict(
|
125 |
input_ids=inputs,
|
|
|
21 |
import torch
|
22 |
import os
|
23 |
|
24 |
+
# Maximum execution time
|
25 |
+
thread_timeout = 600
|
26 |
+
|
27 |
if os.environ.get("HF_TOKEN") is None:
|
28 |
raise ValueError(
|
29 |
"You must set the HF_TOKEN environment variable to use this script, you also need to have access to the Llama 3.2 model family"
|
|
|
122 |
# Start generation on a separate thread, so that we don't block the UI. The text is pulled from the streamer
|
123 |
# in the main thread. Adds timeout to the streamer to handle exceptions in the generation thread.
|
124 |
streamer = TextIteratorStreamer(
|
125 |
+
tokenizer, timeout=thread_timeout, skip_prompt=True, skip_special_tokens=True
|
126 |
)
|
127 |
generate_kwargs = dict(
|
128 |
input_ids=inputs,
|