Shroominic commited on
Commit
11d77f8
Β·
1 Parent(s): b706710

πŸ‘¨πŸ»β€πŸ”¬ dataset analysis example

Browse files
Files changed (1) hide show
  1. examples/analyze_dataset.py +29 -0
examples/analyze_dataset.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from codeinterpreterapi import CodeInterpreterSession
2
+ from codeinterpreterapi.schema import File
3
+
4
+
5
+ async def main():
6
+ # context manager for start/stop of the session
7
+ async with CodeInterpreterSession() as session:
8
+ # define the user request
9
+ user_request = "Analyze this dataset and plot something interesting about it."
10
+ files = [
11
+ File.from_path("examples/assets/iris.csv"),
12
+ ]
13
+
14
+ # generate the response
15
+ response = await session.generate_response(
16
+ user_request, files=files
17
+ )
18
+
19
+ # ouput the response (text + image)
20
+ print("AI: ", response.content)
21
+ for file in response.files:
22
+ file.show_image()
23
+
24
+
25
+ if __name__ == "__main__":
26
+ import asyncio
27
+
28
+ # run the async function
29
+ asyncio.run(main())