Spaces:
Runtime error
Runtime error
whitespace handling
Browse files
app.py
CHANGED
@@ -75,6 +75,10 @@ def process_results(results, highlight_terms):
|
|
75 |
|
76 |
def scisearch(query, language, num_results=10):
|
77 |
try:
|
|
|
|
|
|
|
|
|
78 |
post_data = {"query": query, "k": num_results}
|
79 |
if language != "detect_language":
|
80 |
post_data["lang"] = language
|
@@ -224,13 +228,14 @@ if __name__ == "__main__":
|
|
224 |
flag_btn.click(flag, inputs=[query, lang, k, flag_txt], outputs=[flag_txt])
|
225 |
|
226 |
def submit(query, lang, k):
|
227 |
-
|
228 |
-
|
|
|
229 |
return {
|
230 |
results: scisearch(query, lang, k),
|
231 |
flagging_form: gr.update(visible=True),
|
232 |
}
|
233 |
-
|
234 |
submit_btn.click(submit, inputs=[query, lang, k], outputs=[results, flagging_form])
|
235 |
|
236 |
demo.launch(enable_queue=True, debug=True)
|
|
|
75 |
|
76 |
def scisearch(query, language, num_results=10):
|
77 |
try:
|
78 |
+
query = query.strip()
|
79 |
+
if query == "" or query is None:
|
80 |
+
return ""
|
81 |
+
|
82 |
post_data = {"query": query, "k": num_results}
|
83 |
if language != "detect_language":
|
84 |
post_data["lang"] = language
|
|
|
228 |
flag_btn.click(flag, inputs=[query, lang, k, flag_txt], outputs=[flag_txt])
|
229 |
|
230 |
def submit(query, lang, k):
|
231 |
+
query = query.strip()
|
232 |
+
if query is None or query == "":
|
233 |
+
return "", ""
|
234 |
return {
|
235 |
results: scisearch(query, lang, k),
|
236 |
flagging_form: gr.update(visible=True),
|
237 |
}
|
238 |
+
query.submit(fn=submit, inputs=[query, lang, k], outputs=[results, flagging_form])
|
239 |
submit_btn.click(submit, inputs=[query, lang, k], outputs=[results, flagging_form])
|
240 |
|
241 |
demo.launch(enable_queue=True, debug=True)
|