Update app.py
Browse files
app.py
CHANGED
|
@@ -63,7 +63,7 @@ def save_pdf(file):
|
|
| 63 |
return image_paths
|
| 64 |
|
| 65 |
|
| 66 |
-
def qna_image_content(content, question):
|
| 67 |
result = vision_qna(content, question)
|
| 68 |
page_result = get_page_result(result, question)
|
| 69 |
return get_result_json([all_page_results])
|
|
@@ -87,7 +87,7 @@ def get_result_json(page_results):
|
|
| 87 |
"pages": page_results
|
| 88 |
}
|
| 89 |
return json.dumps(result)
|
| 90 |
-
def qna_pdf_content(image_paths, question):
|
| 91 |
all_page_results = []
|
| 92 |
try:
|
| 93 |
for image_path in image_paths:
|
|
@@ -114,7 +114,7 @@ def answer_the_question_for_doc(file_input, question):
|
|
| 114 |
|
| 115 |
if not question:
|
| 116 |
return "Please provide a question."
|
| 117 |
-
result = qna_pdf_content(image_paths, question)
|
| 118 |
print(result)
|
| 119 |
return result
|
| 120 |
except Exception as e:
|
|
@@ -126,7 +126,7 @@ def answer_the_question_for_doc(file_input, question):
|
|
| 126 |
|
| 127 |
if not question:
|
| 128 |
return "Please provide a question."
|
| 129 |
-
result = qna_image_content(img_file_path, question)
|
| 130 |
print(result)
|
| 131 |
return result[0]["answer"]
|
| 132 |
|
|
|
|
| 63 |
return image_paths
|
| 64 |
|
| 65 |
|
| 66 |
+
def qna_image_content(content, question, vision_qna):
|
| 67 |
result = vision_qna(content, question)
|
| 68 |
page_result = get_page_result(result, question)
|
| 69 |
return get_result_json([all_page_results])
|
|
|
|
| 87 |
"pages": page_results
|
| 88 |
}
|
| 89 |
return json.dumps(result)
|
| 90 |
+
def qna_pdf_content(image_paths, question, vision_qna):
|
| 91 |
all_page_results = []
|
| 92 |
try:
|
| 93 |
for image_path in image_paths:
|
|
|
|
| 114 |
|
| 115 |
if not question:
|
| 116 |
return "Please provide a question."
|
| 117 |
+
result = qna_pdf_content(image_paths, question, vision_qna)
|
| 118 |
print(result)
|
| 119 |
return result
|
| 120 |
except Exception as e:
|
|
|
|
| 126 |
|
| 127 |
if not question:
|
| 128 |
return "Please provide a question."
|
| 129 |
+
result = qna_image_content(img_file_path, question, vision_qna)
|
| 130 |
print(result)
|
| 131 |
return result[0]["answer"]
|
| 132 |
|