Kr08 commited on
Commit
4689853
·
verified ·
1 Parent(s): 3777ba5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -91,7 +91,7 @@ def summarize_text(results):
91
  if summarizer is None:
92
  return "Summarization model could not be loaded."
93
 
94
- summary = summarizer('\n'.join(d['translated'] for d in results if 'translated' in d), max_length=150, min_length=50, do_sample=False)[0]['summary_text']
95
  return summary
96
  except Exception as e:
97
  logger.error(f"Summarization failed: {str(e)}")
@@ -109,7 +109,7 @@ def answer_question(context, question):
109
  return "Please enter your Question"
110
  messages = [
111
  {"role": "system", "content": "You are a helpful assistant who can answer questions based on the given context."},
112
- {"role": "user", "content": f"Context: {'\n'.join(d['translated'] for d in context if 'translated' in d)}\n\nQuestion: {question}"}
113
  ]
114
 
115
  response = qa_pipeline(messages, max_new_tokens=256)[0]['generated_text']
 
91
  if summarizer is None:
92
  return "Summarization model could not be loaded."
93
 
94
+ summary = summarizer(''.join(d['translated'] for d in results if 'translated' in d), max_length=150, min_length=50, do_sample=False)[0]['summary_text']
95
  return summary
96
  except Exception as e:
97
  logger.error(f"Summarization failed: {str(e)}")
 
109
  return "Please enter your Question"
110
  messages = [
111
  {"role": "system", "content": "You are a helpful assistant who can answer questions based on the given context."},
112
+ {"role": "user", "content": f"Context: {''.join(d['translated'] for d in context if 'translated' in d)}\n\nQuestion: {question}"}
113
  ]
114
 
115
  response = qa_pipeline(messages, max_new_tokens=256)[0]['generated_text']