Shroominic commited on
Commit
795fd03
·
1 Parent(s): a53ef66

simplify example

Browse files
Files changed (1) hide show
  1. examples/plot_sin_wave.py +2 -15
examples/plot_sin_wave.py CHANGED
@@ -4,24 +4,11 @@ from codeinterpreterapi import CodeInterpreterSession
4
  async def main():
5
  async with CodeInterpreterSession() as session:
6
  user_request = "Plot a sin wave and show it to me."
 
7
  output = await session.generate_response(user_request)
8
 
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
18
  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
-
25
 
26
  if __name__ == "__main__":
27
  import asyncio
 
4
  async def main():
5
  async with CodeInterpreterSession() as session:
6
  user_request = "Plot a sin wave and show it to me."
7
+
8
  output = await session.generate_response(user_request)
9
 
 
 
 
 
 
 
 
 
 
10
  file = output.files[0]
11
+ file.show_image()
 
 
 
 
 
12
 
13
  if __name__ == "__main__":
14
  import asyncio