Shroominic commited on
Commit
9232844
·
1 Parent(s): 44d7443

🔨 fix async example

Browse files
Files changed (1) hide show
  1. README.md +21 -12
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
- # generate a response based on user input
24
- output = await session.generate_response(
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
- # show output text
32
- print("AI: ", output.content)
 
 
 
 
 
33
 
34
- # terminate the session
35
- await session.stop()
 
 
 
 
 
 
 
 
 
36
 
37
  ```
 
38
  ## Output
39
 
40
  ![Bitcoin YTD](https://github.com/shroominic/codeinterpreter-api/blob/main/examples/assets/bitcoin_chart.png?raw=true)
 
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
  ![Bitcoin YTD](https://github.com/shroominic/codeinterpreter-api/blob/main/examples/assets/bitcoin_chart.png?raw=true)