Update app.py
Browse files
app.py
CHANGED
|
@@ -337,15 +337,23 @@ def main():
|
|
| 337 |
""", unsafe_allow_html=True)
|
| 338 |
|
| 339 |
# Add expanders right after the answer (if additional document references exist)
|
| 340 |
-
if isinstance(content, dict) and 'documents'
|
| 341 |
-
with st.expander("📚 แสดงข้อมูลอ้างอิง", expanded=
|
| 342 |
for i, doc in enumerate(content['documents'], 1):
|
|
|
|
|
|
|
|
|
|
| 343 |
st.markdown(f"""
|
| 344 |
<div style="padding: 1rem; background-color: #F9FAFB; border-radius: 8px; margin: 0.5rem 0;">
|
| 345 |
-
<strong
|
| 346 |
-
{
|
|
|
|
| 347 |
</div>
|
| 348 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
|
| 350 |
# Input section at the bottom
|
| 351 |
with st.container():
|
|
|
|
| 337 |
""", unsafe_allow_html=True)
|
| 338 |
|
| 339 |
# Add expanders right after the answer (if additional document references exist)
|
| 340 |
+
if isinstance(content, dict) and content.get('documents'):
|
| 341 |
+
with st.expander("📚 แสดงข้อมูลอ้างอิง", expanded=True):
|
| 342 |
for i, doc in enumerate(content['documents'], 1):
|
| 343 |
+
doc_content = doc.get('content', 'ไม่มีข้อมูล') # Ensure 'content' key exists
|
| 344 |
+
doc_source = doc.get('source', 'ไม่ทราบแหล่งที่มา') # Add document source info if available
|
| 345 |
+
|
| 346 |
st.markdown(f"""
|
| 347 |
<div style="padding: 1rem; background-color: #F9FAFB; border-radius: 8px; margin: 0.5rem 0;">
|
| 348 |
+
<strong>📄 เอกสารที่ {i}:</strong> <br>
|
| 349 |
+
<em>🔗 แหล่งที่มา: {doc_source}</em> <br><br>
|
| 350 |
+
{doc_content}
|
| 351 |
</div>
|
| 352 |
""", unsafe_allow_html=True)
|
| 353 |
+
else:
|
| 354 |
+
with st.expander("📚 แสดงข้อมูลอ้างอิง", expanded=False):
|
| 355 |
+
st.markdown("<em>ไม่มีข้อมูลอ้างอิงสำหรับคำถามนี้</em>", unsafe_allow_html=True)
|
| 356 |
+
|
| 357 |
|
| 358 |
# Input section at the bottom
|
| 359 |
with st.container():
|