Spaces:
Running
Running
Fix text area reset on window size change
Browse files
app.py
CHANGED
@@ -84,21 +84,22 @@ and offer some initial analyses and insights, including the potential for studyi
|
|
84 |
dependencies.
|
85 |
""".replace("\n", " ").strip()
|
86 |
|
87 |
-
text = st.text_area(
|
88 |
-
f"Input text (≤{max_tokens} tokens)",
|
89 |
-
DEFAULT_TEXT,
|
90 |
-
)
|
91 |
|
92 |
inputs = tokenizer([text])
|
93 |
[input_ids] = inputs["input_ids"]
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
if len(input_ids) < 2:
|
96 |
st.error("Please enter at least 2 tokens.", icon="🚨")
|
97 |
st.stop()
|
98 |
if len(input_ids) > max_tokens:
|
99 |
st.error(
|
100 |
-
f"
|
101 |
-
f"or try reducing the window size.",
|
102 |
icon="🚨"
|
103 |
)
|
104 |
st.stop()
|
|
|
84 |
dependencies.
|
85 |
""".replace("\n", " ").strip()
|
86 |
|
87 |
+
text = st.text_area("Input text", DEFAULT_TEXT)
|
|
|
|
|
|
|
88 |
|
89 |
inputs = tokenizer([text])
|
90 |
[input_ids] = inputs["input_ids"]
|
91 |
|
92 |
+
if len(input_ids) < 2 or len(input_ids) > max_tokens:
|
93 |
+
st.caption(f":red[{len(input_ids)}]/{max_tokens} tokens")
|
94 |
+
else:
|
95 |
+
st.caption(f"{len(input_ids)}/{max_tokens} tokens")
|
96 |
+
|
97 |
if len(input_ids) < 2:
|
98 |
st.error("Please enter at least 2 tokens.", icon="🚨")
|
99 |
st.stop()
|
100 |
if len(input_ids) > max_tokens:
|
101 |
st.error(
|
102 |
+
f"Please enter at most {max_tokens} tokens or try reducing the window size.",
|
|
|
103 |
icon="🚨"
|
104 |
)
|
105 |
st.stop()
|