File size: 784 Bytes
5676d16
11d77f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5c9c9d
11d77f8
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from codeinterpreterapi import CodeInterpreterSession, File


async def main():
    # context manager for start/stop of the session
    async with CodeInterpreterSession() as session:
        # define the user request
        user_request = "Analyze this dataset and plot something interesting about it."
        files = [
            File.from_path("examples/assets/iris.csv"),
        ]
        
        # generate the response
        response = await session.generate_response(
            user_request, files=files
        )

        # output the response (text + image)
        print("AI: ", response.content)
        for file in response.files:
            file.show_image()


if __name__ == "__main__":
    import asyncio

    # run the async function
    asyncio.run(main())