Hasnain-Ali commited on
Commit
ce2b990
·
verified ·
1 Parent(s): 953cc41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -16,9 +16,14 @@ def extract_text_from_pdf(pdf):
16
 
17
  # Function to summarize text
18
  def summarize_text(text):
 
 
 
 
19
  summary = summarizer(text, max_length=200, min_length=50, do_sample=False)
20
  return summary[0]['summary_text']
21
 
 
22
  # Function for Q&A
23
  def answer_question(context, question):
24
  response = qa_model(question=question, context=context)
 
16
 
17
  # Function to summarize text
18
  def summarize_text(text):
19
+ # Limit input to 1024 characters (Bart-large-cnn model limit)
20
+ max_input_length = 1024
21
+ text = text[:max_input_length] # Truncate text to avoid errors
22
+
23
  summary = summarizer(text, max_length=200, min_length=50, do_sample=False)
24
  return summary[0]['summary_text']
25
 
26
+
27
  # Function for Q&A
28
  def answer_question(context, question):
29
  response = qa_model(question=question, context=context)