Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1100,18 +1100,30 @@ if st.session_state.search_results is not None:
|
|
| 1100 |
col1, col2 = st.columns([3,1])
|
| 1101 |
with col1:
|
| 1102 |
st.success(f"Hemos encontrado {len(results)} posible(s) causa(s) relacionada(s) con tu caso.")
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1115 |
|
| 1116 |
with st.expander(f"**An谩lisis Detallado de la Principal Coincidencia: {best_match.get('condicion_asociada')}**", expanded=True):
|
| 1117 |
col1_expander, col2_expander = st.columns([3, 1])
|
|
|
|
| 1100 |
col1, col2 = st.columns([3,1])
|
| 1101 |
with col1:
|
| 1102 |
st.success(f"Hemos encontrado {len(results)} posible(s) causa(s) relacionada(s) con tu caso.")
|
| 1103 |
+
|
| 1104 |
+
with col2:
|
| 1105 |
+
# Bot贸n de descarga 煤nico con mensaje informativo
|
| 1106 |
+
if st.button("馃搫 Descargar Informe (Word)", help="La generaci贸n del informe puede tomar algunos segundos."):
|
| 1107 |
+
with st.spinner("Generando su informe personalizado, por favor espere..."):
|
| 1108 |
+
# Generar todo el contenido del informe en el momento
|
| 1109 |
+
ai_analysis_text = st.session_state.analysis_cache.get('best_match_analysis', "An谩lisis con IA no generado.")
|
| 1110 |
+
base_report_text = generate_report_text(st.session_state.user_query, results)
|
| 1111 |
+
neuro_report_text = generate_neuro_report_text(st.session_state.entities, FOOD_TO_COMPOUND_MAP, INTEGRATED_NEURO_FOOD_MAP)
|
| 1112 |
+
molecular_report_text = generate_molecular_report_text(best_match, st.session_state.entities, foodb_index, FOOD_NAME_TO_FOODB_KEY, COMPOUND_SYNONYM_MAP, KNOWN_TRIGGERS_MAP)
|
| 1113 |
+
|
| 1114 |
+
complete_report_string = f"{base_report_text}\n\n{ai_analysis_text}\n{neuro_report_text}\n{molecular_report_text}"
|
| 1115 |
+
|
| 1116 |
+
word_file_buffer = generate_word_report(complete_report_string)
|
| 1117 |
+
|
| 1118 |
+
# Preparar el bot贸n de descarga oculto para que Streamlit lo muestre al finalizar el spinner
|
| 1119 |
+
if word_file_buffer:
|
| 1120 |
+
st.download_button(
|
| 1121 |
+
label="Descarga lista", # Esta etiqueta no ser谩 visible para el usuario
|
| 1122 |
+
data=word_file_buffer,
|
| 1123 |
+
file_name=f"Informe_Detective_Alimentos_{datetime.now().strftime('%Y%m%d')}.docx",
|
| 1124 |
+
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 1125 |
+
key="download_word_report_final"
|
| 1126 |
+
)
|
| 1127 |
|
| 1128 |
with st.expander(f"**An谩lisis Detallado de la Principal Coincidencia: {best_match.get('condicion_asociada')}**", expanded=True):
|
| 1129 |
col1_expander, col2_expander = st.columns([3, 1])
|