Spaces:
Runtime error
Runtime error
Shroominic
commited on
Commit
·
9232844
1
Parent(s):
44d7443
🔨 fix async example
Browse files
README.md
CHANGED
|
@@ -18,23 +18,32 @@ from codeinterpreterapi import CodeInterpreterSession
|
|
| 18 |
|
| 19 |
# start a session
|
| 20 |
session = CodeInterpreterSession()
|
| 21 |
-
await session.astart()
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
"Plot the bitcoin chart of 2023 YTD"
|
| 26 |
-
)
|
| 27 |
-
# show output image in default image viewer
|
| 28 |
-
file = output.files[0]
|
| 29 |
-
file.show_image()
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
```
|
|
|
|
| 38 |
## Output
|
| 39 |
|
| 40 |

|
|
|
|
| 18 |
|
| 19 |
# start a session
|
| 20 |
session = CodeInterpreterSession()
|
|
|
|
| 21 |
|
| 22 |
+
async def main():
|
| 23 |
+
await session.astart()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
# generate a response based on user input
|
| 26 |
+
output = await session.generate_response(
|
| 27 |
+
"Plot the bitcoin chart of 2023 YTD"
|
| 28 |
+
)
|
| 29 |
+
# show output image in default image viewer
|
| 30 |
+
file = output.files[0]
|
| 31 |
+
file.show_image()
|
| 32 |
|
| 33 |
+
# show output text
|
| 34 |
+
print("AI: ", output.content)
|
| 35 |
+
|
| 36 |
+
# terminate the session
|
| 37 |
+
await session.astop()
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
import asyncio
|
| 42 |
+
|
| 43 |
+
asyncio.run(main())
|
| 44 |
|
| 45 |
```
|
| 46 |
+
|
| 47 |
## Output
|
| 48 |
|
| 49 |

|