Skip to content

Commit 795fd03

Browse files
committed
simplify example
1 parent a53ef66 commit 795fd03

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

examples/plot_sin_wave.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,11 @@
44
async def main():
55
async with CodeInterpreterSession() as session:
66
user_request = "Plot a sin wave and show it to me."
7+
78
output = await session.generate_response(user_request)
89

9-
print(output.content)
10-
11-
try:
12-
from PIL import Image # type: ignore
13-
except ImportError:
14-
print("Please install it with `pip install codeinterpreterapi[image_support]` to display images.")
15-
exit(1)
16-
17-
from io import BytesIO
1810
file = output.files[0]
19-
img_io = BytesIO(file.content)
20-
img = Image.open(img_io)
21-
22-
# Display the image
23-
img.show()
24-
11+
file.show_image()
2512

2613
if __name__ == "__main__":
2714
import asyncio

0 commit comments

Comments
 (0)