Commit
·
8155afc
1
Parent(s):
e614a79
Update app.py
Browse files
app.py
CHANGED
@@ -96,18 +96,17 @@ class DocumentQA:
|
|
96 |
Raises:
|
97 |
ValueError: If an error occurs during the process.
|
98 |
"""
|
99 |
-
|
100 |
-
total_chemical=[]
|
101 |
-
|
102 |
for url in urls.split(','):
|
103 |
-
webpage_text
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
109 |
|
110 |
-
return
|
111 |
|
112 |
|
113 |
|
@@ -155,24 +154,23 @@ class DocumentQA:
|
|
155 |
|
156 |
|
157 |
file_paths = [single_file_path.name for single_file_path in file_paths]
|
158 |
-
|
159 |
for file_obj in file_paths:
|
160 |
|
161 |
loader = UnstructuredFileLoader(file_obj, strategy="fast")
|
162 |
|
163 |
# Load the contents of the file using the loader
|
164 |
-
docs
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
# Return a tuple containing the file name and the knowledge base
|
175 |
-
return
|
176 |
|
177 |
def get_final_result(self,urls,file_paths,state,input_qus):
|
178 |
|
|
|
96 |
Raises:
|
97 |
ValueError: If an error occurs during the process.
|
98 |
"""
|
99 |
+
webpage_text =''
|
|
|
|
|
100 |
for url in urls.split(','):
|
101 |
+
webpage_text += self.get_content_from_url(url)
|
102 |
+
|
103 |
+
knowledge_base = self.create_knowledge_base(webpage_text)
|
104 |
+
|
105 |
+
state = {"knowledge_base": knowledge_base}
|
106 |
+
|
107 |
+
chemicals = self.get_chemicals_for_file(state,input_qus)
|
108 |
|
109 |
+
return chemicals
|
110 |
|
111 |
|
112 |
|
|
|
154 |
|
155 |
|
156 |
file_paths = [single_file_path.name for single_file_path in file_paths]
|
157 |
+
docs =''
|
158 |
for file_obj in file_paths:
|
159 |
|
160 |
loader = UnstructuredFileLoader(file_obj, strategy="fast")
|
161 |
|
162 |
# Load the contents of the file using the loader
|
163 |
+
docs +=loader.load()
|
164 |
+
|
165 |
+
# Create a knowledge base from the loaded documents using the create_knowledge_base() method
|
166 |
+
knowledge_base = self.create_knowledge_base(docs)
|
167 |
+
state = {"knowledge_base": knowledge_base}
|
168 |
+
pdf_name = os.path.basename(file_obj)
|
169 |
+
|
170 |
+
final_ans = self.get_chemicals_for_file(state,question)
|
171 |
+
|
|
|
172 |
# Return a tuple containing the file name and the knowledge base
|
173 |
+
return final_ans
|
174 |
|
175 |
def get_final_result(self,urls,file_paths,state,input_qus):
|
176 |
|