yonikremer
commited on
Commit
•
e63724c
1
Parent(s):
0e07a66
more exception handling
Browse files- hanlde_form_submit.py +6 -1
hanlde_form_submit.py
CHANGED
@@ -78,8 +78,13 @@ def on_form_submit(model_name: str, output_length: int, prompt: str) -> str:
|
|
78 |
model_name=model_name,
|
79 |
group_size=output_length,
|
80 |
)
|
81 |
-
|
82 |
pipeline=pipeline,
|
83 |
prompt=prompt,
|
84 |
output_length=output_length,
|
85 |
)
|
|
|
|
|
|
|
|
|
|
|
|
78 |
model_name=model_name,
|
79 |
group_size=output_length,
|
80 |
)
|
81 |
+
generated_text = generate_text(
|
82 |
pipeline=pipeline,
|
83 |
prompt=prompt,
|
84 |
output_length=output_length,
|
85 |
)
|
86 |
+
if not isinstance(generated_text, str):
|
87 |
+
raise RuntimeError(f"The model {model_name} did not generate any text.")
|
88 |
+
if len(generated_text) == 0:
|
89 |
+
raise RuntimeError(f"The model {model_name} did not generate any text.")
|
90 |
+
return generated_text
|