Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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
|
78 |
result = nlp_qa({
|
79 |
-
'question': question,
|
80 |
-
'context':
|
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 |
|