Skip to content

Commit

Permalink
🔧 temp fix old streamlit
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Sep 3, 2023
1 parent b408c00 commit 4e2e32e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions frontend/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import asyncio
import sys

import streamlit as st # type: ignore
import streamlit as st

from codeinterpreterapi import File
from utils import get_images
from frontend.utils import get_images

# Page configuration
st.set_page_config(layout="wide")
Expand All @@ -26,7 +26,7 @@
uploaded_files_list.append(File(name=uploaded_file.name, content=bytes_data))

# This will create a button
button_pressed = st.button("Run code interpreter", use_container_width=True)
button_pressed = st.button("Run code interpreter api")

# This will display the images only when the button is pressed
if button_pressed and input_text != "":
Expand Down
8 changes: 3 additions & 5 deletions frontend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tempfile
from typing import Optional

import streamlit as st # type: ignore
import streamlit as st

from codeinterpreterapi import CodeInterpreterSession

Expand All @@ -19,13 +19,13 @@ def create_temp_folder() -> str:
async def get_images(prompt: str, files: Optional[list] = None):
if files is None:
files = []
with st.chat_message("user"):
with st.chat_message("user"): # type: ignore
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"):
with st.chat_message("assistant"): # type: ignore
st.write(response.content)

# Showing Results
Expand All @@ -38,7 +38,6 @@ async def get_images(prompt: str, files: Optional[list] = None):
"Download Results",
response.files[0].content,
file_name=response.files[0].name,
use_container_width=True,
)
else:
target_path = tempfile.mkdtemp()
Expand All @@ -53,5 +52,4 @@ async def get_images(prompt: str, files: Optional[list] = None):
"Download Results",
f,
file_name="archive.zip",
use_container_width=True,
)

0 comments on commit 4e2e32e

Please sign in to comment.