Spaces:
Runtime error
Runtime error
🚸 provide details on truncation
Browse filesSigned-off-by: peter szemraj <[email protected]>
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import contextlib
|
2 |
import logging
|
|
|
3 |
import time
|
4 |
from pathlib import Path
|
5 |
|
@@ -68,7 +69,14 @@ def proc_submission(
|
|
68 |
|
69 |
if processed["was_truncated"]:
|
70 |
tr_in = processed["truncated_text"]
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
logging.warning(msg)
|
73 |
history["WARNING"] = msg
|
74 |
else:
|
|
|
1 |
import contextlib
|
2 |
import logging
|
3 |
+
import re
|
4 |
import time
|
5 |
from pathlib import Path
|
6 |
|
|
|
69 |
|
70 |
if processed["was_truncated"]:
|
71 |
tr_in = processed["truncated_text"]
|
72 |
+
# create elaborate HTML warning
|
73 |
+
input_wc = re.split(r"\s+", input_text)
|
74 |
+
msg = f"""
|
75 |
+
<div style="background-color: #f44336; color: white; padding: 20px;">
|
76 |
+
<h3>Warning</h3>
|
77 |
+
<p>Input text was truncated to {max_input_length} words. This is about {100*max_input_length/len(input_wc):.2f}% of the submission.</p>
|
78 |
+
</div>
|
79 |
+
"""
|
80 |
logging.warning(msg)
|
81 |
history["WARNING"] = msg
|
82 |
else:
|