Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,12 +61,12 @@ class CSVChatbot:
|
|
| 61 |
result = self.agent.run(CSV_PROMPT_PREFIX + message + CSV_PROMPT_SUFFIX)
|
| 62 |
fig = plt.gcf()
|
| 63 |
if fig.get_axes():
|
| 64 |
-
plt.clf()
|
| 65 |
buf = io.BytesIO()
|
| 66 |
fig.savefig(buf, format='png')
|
| 67 |
buf.seek(0)
|
| 68 |
img_str = base64.b64encode(buf.getvalue()).decode()
|
| 69 |
img_markdown = f""
|
|
|
|
| 70 |
plt.close(fig) # Close the figure to free up memory
|
| 71 |
return result + "\n\n" + img_markdown
|
| 72 |
else:
|
|
|
|
| 61 |
result = self.agent.run(CSV_PROMPT_PREFIX + message + CSV_PROMPT_SUFFIX)
|
| 62 |
fig = plt.gcf()
|
| 63 |
if fig.get_axes():
|
|
|
|
| 64 |
buf = io.BytesIO()
|
| 65 |
fig.savefig(buf, format='png')
|
| 66 |
buf.seek(0)
|
| 67 |
img_str = base64.b64encode(buf.getvalue()).decode()
|
| 68 |
img_markdown = f""
|
| 69 |
+
plt.clf() # Clear the figure after saving to buffer
|
| 70 |
plt.close(fig) # Close the figure to free up memory
|
| 71 |
return result + "\n\n" + img_markdown
|
| 72 |
else:
|