Spaces:
Sleeping
Sleeping
Zeggai Abdellah
commited on
Commit
·
4346bfa
1
Parent(s):
bb594f6
fix the process_question_with_citations
Browse files- rag_pipeline.py +6 -5
rag_pipeline.py
CHANGED
|
@@ -279,10 +279,11 @@ def process_question_with_citations(agent, question: str, chunks_directory="./da
|
|
| 279 |
# Get only the cited elements
|
| 280 |
cited_elements = []
|
| 281 |
for element in all_chunks_data:
|
| 282 |
-
if element.get("
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
|
|
|
| 286 |
for nested_element in element["elements"]:
|
| 287 |
if nested_element.get("element_id") in unique_ids:
|
| 288 |
cited_elements.append(nested_element)
|
|
@@ -299,7 +300,7 @@ def process_question_with_citations(agent, question: str, chunks_directory="./da
|
|
| 299 |
except Exception as e:
|
| 300 |
print(f"Error processing question: {e}")
|
| 301 |
return {
|
| 302 |
-
"response":
|
| 303 |
"cited_elements_json": "[]",
|
| 304 |
"unique_ids": []
|
| 305 |
}
|
|
|
|
| 279 |
# Get only the cited elements
|
| 280 |
cited_elements = []
|
| 281 |
for element in all_chunks_data:
|
| 282 |
+
if element.get("type") =='TableElement':
|
| 283 |
+
if element.get("element_id") in unique_ids:
|
| 284 |
+
cited_elements.append(element['elements'])
|
| 285 |
+
else :
|
| 286 |
+
if "elements" in element:
|
| 287 |
for nested_element in element["elements"]:
|
| 288 |
if nested_element.get("element_id") in unique_ids:
|
| 289 |
cited_elements.append(nested_element)
|
|
|
|
| 300 |
except Exception as e:
|
| 301 |
print(f"Error processing question: {e}")
|
| 302 |
return {
|
| 303 |
+
"response": response_text,
|
| 304 |
"cited_elements_json": "[]",
|
| 305 |
"unique_ids": []
|
| 306 |
}
|