AIdeaText commited on
Commit
aef46ee
·
verified ·
1 Parent(s): 10eddfe

Update modules/discourse/discourse_interface.py

Browse files
modules/discourse/discourse_interface.py CHANGED
@@ -199,18 +199,27 @@ def display_discourse_results(result, lang_code, discourse_t):
199
  """
200
  st.markdown(concepts_html, unsafe_allow_html=True)
201
 
 
202
  if 'graph1' in result:
203
  st.markdown('<div class="graph-container">', unsafe_allow_html=True)
204
 
205
- # Verificar el tipo de graph1
206
- if isinstance(result['graph1'], plt.Figure):
207
- # Es una figura de matplotlib directamente
208
- st.pyplot(result['graph1'])
209
- elif isinstance(result['graph1'], bytes):
210
- # Es bytes, mostrar como imagen
 
211
  st.image(result['graph1'])
 
 
 
 
 
 
212
  else:
213
- st.warning("Formato de gráfico no reconocido")
 
214
 
215
  # Botones y controles
216
  button_col1, spacer_col1 = st.columns([1,4])
@@ -255,18 +264,27 @@ def display_discourse_results(result, lang_code, discourse_t):
255
  """
256
  st.markdown(concepts_html, unsafe_allow_html=True)
257
 
258
- if 'graph2' in result:
 
259
  st.markdown('<div class="graph-container">', unsafe_allow_html=True)
260
 
261
- # Verificar el tipo de graph2
262
- if isinstance(result['graph2'], plt.Figure):
263
- # Es una figura de matplotlib directamente
264
- st.pyplot(result['graph2'])
265
- elif isinstance(result['graph2'], bytes):
266
- # Es bytes, mostrar como imagen
 
267
  st.image(result['graph2'])
 
 
 
 
 
 
268
  else:
269
- st.warning("Formato de gráfico no reconocido")
 
270
 
271
  # Botones y controles
272
  button_col2, spacer_col2 = st.columns([1,4])
 
199
  """
200
  st.markdown(concepts_html, unsafe_allow_html=True)
201
 
202
+ # Verificar el tipo de graph1 de manera más robusta
203
  if 'graph1' in result:
204
  st.markdown('<div class="graph-container">', unsafe_allow_html=True)
205
 
206
+ # Más información para depuración
207
+ graph_type = type(result['graph1']).__name__
208
+ graph_size = len(result['graph1']) if isinstance(result['graph1'], bytes) else "N/A"
209
+ logger.info(f"Tipo de graph1: {graph_type}, Tamaño: {graph_size}")
210
+
211
+ if isinstance(result['graph1'], bytes) and len(result['graph1']) > 0:
212
+ # Es bytes válidos
213
  st.image(result['graph1'])
214
+ elif isinstance(result['graph1'], plt.Figure):
215
+ # Es una figura de matplotlib
216
+ st.pyplot(result['graph1'])
217
+ elif result['graph1'] is None:
218
+ # Es None
219
+ st.warning("Gráfico no disponible")
220
  else:
221
+ # Otro tipo o bytes vacíos
222
+ st.warning(f"Formato de gráfico no reconocido: {graph_type}")
223
 
224
  # Botones y controles
225
  button_col1, spacer_col1 = st.columns([1,4])
 
264
  """
265
  st.markdown(concepts_html, unsafe_allow_html=True)
266
 
267
+ # Verificar el tipo de graph1 de manera más robusta
268
+ if 'graph1' in result:
269
  st.markdown('<div class="graph-container">', unsafe_allow_html=True)
270
 
271
+ # Más información para depuración
272
+ graph_type = type(result['graph2']).__name__
273
+ graph_size = len(result['graph2']) if isinstance(result['graph2'], bytes) else "N/A"
274
+ logger.info(f"Tipo de graph2: {graph_type}, Tamaño: {graph_size}")
275
+
276
+ if isinstance(result['graph2'], bytes) and len(result['graph2']) > 0:
277
+ # Es bytes válidos
278
  st.image(result['graph2'])
279
+ elif isinstance(result['graph2'], plt.Figure):
280
+ # Es una figura de matplotlib
281
+ st.pyplot(result['graph2'])
282
+ elif result['graph2'] is None:
283
+ # Es None
284
+ st.warning("Gráfico no disponible")
285
  else:
286
+ # Otro tipo o bytes vacíos
287
+ st.warning(f"Formato de gráfico no reconocido: {graph_type}")
288
 
289
  # Botones y controles
290
  button_col2, spacer_col2 = st.columns([1,4])