I encountered an issue while using the @e2b/code-interpreter package to run a Python script for generating a bar chart. The chart property in the result.results[0] object is undefined, even though the script executes successfully. only text and png is returned. Below is the code snippet I used:
import { Sandbox, BarChart } from '@e2b/code-interpreter'
const code = `
import matplotlib.pyplot as plt
# Prepare data
authors = ['Author A', 'Author B', 'Author C', 'Author D']
sales = [100, 200, 300, 400]
# Create and customize the bar chart
plt.figure(figsize=(10, 6))
plt.bar(authors, sales, label='Books Sold', color='blue')
plt.xlabel('Authors')
plt.ylabel('Number of Books Sold')
plt.title('Book Sales by Authors')
# Display the chart
plt.tight_layout()
plt.show()
`
const sandbox = await Sandbox.create()
const result = await sandbox.runCode(code)
const chart = result.results[0].chart as BarChart
console.log(chart) // chart is undefined