handle long inputs
Browse files
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 |
|