MJobe commited on
Commit
2181fee
1 Parent(s): 3fa2b10

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -10
main.py CHANGED
@@ -63,21 +63,15 @@ async def load_file(
63
  questions: str = Form(...),
64
  ):
65
  try:
66
- # Read the uploaded file
67
  contents = await file.read()
68
 
69
- # Convert binary content to text
70
- text_content = contents.decode('utf-8')
71
-
72
- # Split the questions string into a list
73
- question_list = [q.strip() for q in questions.split(',')]
74
-
75
  # Perform document question answering for each question using BERT-based model
76
  answers_dict = {}
77
- for question in question_list:
78
  result = nlp_qa({
79
- 'question': question,
80
- 'context': text_content
81
  })
82
  answers_dict[question] = result['answer']
83
 
 
63
  questions: str = Form(...),
64
  ):
65
  try:
66
+ # Read the uploaded file as bytes
67
  contents = await file.read()
68
 
 
 
 
 
 
 
69
  # Perform document question answering for each question using BERT-based model
70
  answers_dict = {}
71
+ for question in questions.split(','):
72
  result = nlp_qa({
73
+ 'question': question.strip(),
74
+ 'context': contents.decode('utf-8') # Assuming the content is text, adjust as needed
75
  })
76
  answers_dict[question] = result['answer']
77