Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -173,23 +173,30 @@ if prompt:
|
|
173 |
print(f"\nFull result: {agent.last_result}\n")
|
174 |
|
175 |
full_result = agent.last_result
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
elapsed_time = time.time() - start_time
|
179 |
print(f"\nExecution time: {elapsed_time:.2f} seconds\n")
|
180 |
|
181 |
-
if isinstance(answer, str) and os.path.isfile(answer):
|
182 |
-
# Si el output es una ruta válida a imagen
|
183 |
-
im = plt.imread(answer)
|
184 |
-
st.image(im)
|
185 |
-
os.remove(answer) # Limpiar archivo temporal
|
186 |
-
|
187 |
-
if explanation:
|
188 |
-
st.markdown(f"**Explanation:** {explanation}")
|
189 |
-
else:
|
190 |
-
# Si no es una ruta válida, mostrar como texto
|
191 |
-
st.markdown(str(answer))
|
192 |
-
|
193 |
except Exception as e:
|
194 |
st.error(f"Error generating answer: {e}")
|
195 |
|
|
|
173 |
print(f"\nFull result: {agent.last_result}\n")
|
174 |
|
175 |
full_result = agent.last_result
|
176 |
+
|
177 |
+
if full_result is not None and isinstance(full_result, dict):
|
178 |
+
explanation = full_result.get("explanation", "")
|
179 |
+
if isinstance(answer, str) and os.path.isfile(answer):
|
180 |
+
# Si el output es una ruta válida a imagen
|
181 |
+
im = plt.imread(answer)
|
182 |
+
st.image(im)
|
183 |
+
os.remove(answer) # Limpiar archivo temporal
|
184 |
+
|
185 |
+
if explanation:
|
186 |
+
st.markdown(f"**Explanation:** {explanation}")
|
187 |
+
else:
|
188 |
+
# Si no es una ruta válida, mostrar como texto
|
189 |
+
st.markdown(str(answer))
|
190 |
+
else:
|
191 |
+
st.markdown("No se pudo generar una respuesta estructurada.")
|
192 |
+
if full_result is not None:
|
193 |
+
print(f"Error: `full_result` no es un diccionario: {full_result}")
|
194 |
+
else:
|
195 |
+
print("Error: `full_result` es None.")
|
196 |
|
197 |
elapsed_time = time.time() - start_time
|
198 |
print(f"\nExecution time: {elapsed_time:.2f} seconds\n")
|
199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
except Exception as e:
|
201 |
st.error(f"Error generating answer: {e}")
|
202 |
|