File size: 677 Bytes
b1ef552
 
 
 
747a11a
 
 
b1ef552
 
 
 
 
747a11a
 
b1ef552
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from codeinterpreterapi import CodeInterpreterSession
import streamlit as st


async def get_images(prompt: str, files: list = None):
    if files is None:
        files = []
    with st.chat_message("user"):
        st.write(prompt)
    with st.spinner():
        async with CodeInterpreterSession(model='gpt-3.5-turbo') as session:
            response = await session.generate_response(
                prompt,
                files=files
            )

            with st.chat_message("assistant"):
                st.write(response.content)

                for file in response.files:
                    st.image(file.get_image(), caption=prompt, use_column_width=True)