Spaces:
Sleeping
Sleeping
render expander through markdown element
Browse files
app.py
CHANGED
|
@@ -144,15 +144,23 @@ def retriever(query: str, selected_retriever: str):
|
|
| 144 |
|
| 145 |
corpus = '\n\n'.join(topk_documents)
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
for idx, document in enumerate(topk_documents):
|
| 148 |
try:
|
| 149 |
idx = document.lower().index("abstract:")
|
| 150 |
title = document[:idx].replace('\n', ' ')
|
| 151 |
doc_details = document[idx:]
|
| 152 |
with st.expander(f"Rank {ix+1} - {title}"):
|
| 153 |
-
st.
|
| 154 |
except:
|
| 155 |
-
|
| 156 |
|
| 157 |
# retrieved_document_titles = ""
|
| 158 |
# for document in topk_documents:
|
|
|
|
| 144 |
|
| 145 |
corpus = '\n\n'.join(topk_documents)
|
| 146 |
|
| 147 |
+
if "last_expander_id" not in st.session_state:
|
| 148 |
+
st.session_state.last_expander_id = 0
|
| 149 |
+
|
| 150 |
+
# Function to create a unique key for each expander
|
| 151 |
+
def get_expander_key():
|
| 152 |
+
st.session_state.last_expander_id += 1
|
| 153 |
+
return f"expander_{st.session_state.last_expander_id}"
|
| 154 |
+
|
| 155 |
for idx, document in enumerate(topk_documents):
|
| 156 |
try:
|
| 157 |
idx = document.lower().index("abstract:")
|
| 158 |
title = document[:idx].replace('\n', ' ')
|
| 159 |
doc_details = document[idx:]
|
| 160 |
with st.expander(f"Rank {ix+1} - {title}"):
|
| 161 |
+
st.markdown(f"{doc_details}")
|
| 162 |
except:
|
| 163 |
+
print("Document parsing error for title and other contents")
|
| 164 |
|
| 165 |
# retrieved_document_titles = ""
|
| 166 |
# for document in topk_documents:
|