Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -39,17 +39,22 @@ def model(model_name):
|
|
39 |
def qa_result(context, question, file_path):
|
40 |
model_name = "timpal0l/mdeberta-v3-base-squad2"
|
41 |
pipe = model(model_name)
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
elif len(context) == 0:
|
46 |
text = "Ես չեմ կարողանամ քեզ օգնել եթե ինձ չտրամադրես տեքստը"
|
47 |
elif len(question) == 0:
|
48 |
text = "Ես չեմ կարողանամ քեզ օգնել եթե ինձ չտաս հարցդ"
|
49 |
else:
|
50 |
-
if file_path is not None:
|
51 |
-
|
52 |
-
|
53 |
# else: No file uploaded, use the provided context as is
|
54 |
result = pipe(question=question, context=context)
|
55 |
answered = result['answer']
|
|
|
39 |
def qa_result(context, question, file_path):
|
40 |
model_name = "timpal0l/mdeberta-v3-base-squad2"
|
41 |
pipe = model(model_name)
|
42 |
+
if file_path is not None:
|
43 |
+
context = extract_text_from_pdf(file_path)
|
44 |
+
result = pipe(question=question, context=context)
|
45 |
+
answered = result['answer']
|
46 |
+
text = remove_references(answered)
|
47 |
+
|
48 |
+
elif len(context) == 0 and len(question) == 0::
|
49 |
+
text = "Որպեսզի ես կարողանամ քեզ օգնել, ինձ պիտի տրամադրես համապատասխան տեքստն ու հարցերը։"
|
50 |
elif len(context) == 0:
|
51 |
text = "Ես չեմ կարողանամ քեզ օգնել եթե ինձ չտրամադրես տեքստը"
|
52 |
elif len(question) == 0:
|
53 |
text = "Ես չեմ կարողանամ քեզ օգնել եթե ինձ չտաս հարցդ"
|
54 |
else:
|
55 |
+
# if file_path is not None:
|
56 |
+
# # File was uploaded, extract text from the file
|
57 |
+
# context = extract_text_from_pdf(file_path)
|
58 |
# else: No file uploaded, use the provided context as is
|
59 |
result = pipe(question=question, context=context)
|
60 |
answered = result['answer']
|