rasyosef commited on
Commit
0858c92
·
verified ·
1 Parent(s): 1abb0b0

handle long inputs

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -94,6 +94,9 @@ def generate(question, answer, text_file, max_new_tokens):
94
 
95
  query = f"{question}"
96
 
 
 
 
97
  thread = Thread(target=qa_chain.invoke, kwargs={"input": {"query": query}})
98
  thread.start()
99
 
 
94
 
95
  query = f"{question}"
96
 
97
+ if len(tokenizer.tokenize(query)) >= 512:
98
+ query = "Repeat 'Your question is too long!'"
99
+
100
  thread = Thread(target=qa_chain.invoke, kwargs={"input": {"query": query}})
101
  thread.start()
102