Spaces:
Runtime error
Runtime error
Shroominic
commited on
Commit
·
c26a364
1
Parent(s):
11d77f8
🛀 cleanup examples
Browse files- examples/plot_sin_wave.py +6 -5
- examples/show_bitcoin_chart.py +13 -10
examples/plot_sin_wave.py
CHANGED
|
@@ -3,12 +3,13 @@ from codeinterpreterapi import CodeInterpreterSession
|
|
| 3 |
|
| 4 |
async def main():
|
| 5 |
async with CodeInterpreterSession() as session:
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
file.show_image()
|
| 12 |
|
| 13 |
|
| 14 |
if __name__ == "__main__":
|
|
|
|
| 3 |
|
| 4 |
async def main():
|
| 5 |
async with CodeInterpreterSession() as session:
|
| 6 |
+
response = await session.generate_response(
|
| 7 |
+
"Plot a sin wave and show it to me."
|
| 8 |
+
)
|
| 9 |
|
| 10 |
+
print("AI: ", response.content)
|
| 11 |
+
for file in response.files:
|
| 12 |
+
file.show_image()
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
if __name__ == "__main__":
|
examples/show_bitcoin_chart.py
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from datetime import datetime
|
| 2 |
from codeinterpreterapi import CodeInterpreterSession
|
| 3 |
|
|
@@ -5,18 +12,14 @@ from codeinterpreterapi import CodeInterpreterSession
|
|
| 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 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
# and plot it for you
|
| 20 |
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The exciting part about this example is
|
| 3 |
+
that the code interpreter has internet access
|
| 4 |
+
so it can download the bitcoin chart from yahoo finance
|
| 5 |
+
and plot it for you
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
from datetime import datetime
|
| 9 |
from codeinterpreterapi import CodeInterpreterSession
|
| 10 |
|
|
|
|
| 12 |
async def main():
|
| 13 |
async with CodeInterpreterSession() as session:
|
| 14 |
currentdate = datetime.now().strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
response = await session.generate_response(
|
| 17 |
+
f"Plot the bitcoin chart of 2023 YTD (today is {currentdate})"
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
print("AI: ", response.content)
|
| 21 |
+
for file in response.files:
|
| 22 |
+
file.show_image()
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|