Spaces:
Runtime error
Runtime error
Shroominic
commited on
Commit
·
c205933
1
Parent(s):
795fd03
bitcoin chart example
Browse files
examples/show_bitcoin_chart.py
CHANGED
|
@@ -1 +1,24 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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())
|