Skip to content

Commit c205933

Browse files
committed
bitcoin chart example
1 parent 795fd03 commit c205933

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

examples/show_bitcoin_chart.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
# TODO: ask the agent to plot the bitcoin chart of 2023 YTD (today is {{currentdate}}) - show the output to the user with PIL.show()
1+
from datetime import datetime
2+
from codeinterpreterapi import CodeInterpreterSession
3+
4+
5+
async def main():
6+
async with CodeInterpreterSession() as session:
7+
currentdate = datetime.now().strftime("%Y-%m-%d")
8+
user_request = f"Plot the bitcoin chart of 2023 YTD (today is {currentdate})"
9+
10+
output = await session.generate_response(user_request)
11+
12+
file = output.files[0]
13+
file.show_image()
14+
15+
16+
# The exciting part about this example is
17+
# that the code interpreter has internet access
18+
# so it can download the bitcoin chart from yahoo finance
19+
# and plot it for you
20+
21+
22+
if __name__ == "__main__":
23+
import asyncio
24+
asyncio.run(main())

0 commit comments

Comments
 (0)