Skip to content

Commit

Permalink
simplify example
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Jul 14, 2023
1 parent a53ef66 commit 795fd03
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions examples/plot_sin_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@
async def main():
async with CodeInterpreterSession() as session:
user_request = "Plot a sin wave and show it to me."

output = await session.generate_response(user_request)

print(output.content)

try:
from PIL import Image # type: ignore
except ImportError:
print("Please install it with `pip install codeinterpreterapi[image_support]` to display images.")
exit(1)

from io import BytesIO
file = output.files[0]
img_io = BytesIO(file.content)
img = Image.open(img_io)

# Display the image
img.show()

file.show_image()

if __name__ == "__main__":
import asyncio
Expand Down

0 comments on commit 795fd03

Please sign in to comment.