update
Browse files
app.py
CHANGED
@@ -149,19 +149,24 @@ def inference_gen(text, task, do_sample, top_p, top_k, max_token, temperature, b
|
|
149 |
#print(generate_config)
|
150 |
#print(text)
|
151 |
default_example = default_example and generate_config == default_generate_config
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
return prediction.generations[0].text
|
167 |
|
|
|
149 |
#print(generate_config)
|
150 |
#print(text)
|
151 |
default_example = default_example and generate_config == default_generate_config
|
152 |
+
try_num = 3
|
153 |
+
while try_num:
|
154 |
+
try:
|
155 |
+
if default_example:
|
156 |
+
prediction = cl.generate(
|
157 |
+
model_name='clueai-base',
|
158 |
+
prompt=text)
|
159 |
+
else:
|
160 |
+
prediction = cl.generate(
|
161 |
+
model_name='clueai-base',
|
162 |
+
prompt=text,
|
163 |
+
generate_config=generate_config)
|
164 |
+
except Exception as e:
|
165 |
+
logger.error(f"error, {e}")
|
166 |
+
return
|
167 |
+
if prediction.generations[0].text != "含有违规词,不予展示":
|
168 |
+
break
|
169 |
+
try_num -= 1
|
170 |
|
171 |
return prediction.generations[0].text
|
172 |
|