Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
|
| 3 |
+
import streamlit as st # type: ignore
|
| 4 |
+
|
| 5 |
+
from codeinterpreterapi import File
|
| 6 |
+
from utils import get_images
|
| 7 |
+
|
| 8 |
+
# Page configuration
|
| 9 |
+
st.set_page_config(layout="wide")
|
| 10 |
+
|
| 11 |
+
st.title("Code Interpreter API π")
|
| 12 |
+
|
| 13 |
+
# This will create a sidebar
|
| 14 |
+
st.sidebar.title("Code Interpreter API π")
|
| 15 |
+
st.sidebar.markdown("[Github Repo](https://github.com/shroominic/codeinterpreter-api)")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# This will create a textbox where you can input text
|
| 19 |
+
input_text = st.text_area("Write your prompt")
|
| 20 |
+
uploaded_files = st.file_uploader("Upload your files", accept_multiple_files=True)
|
| 21 |
+
|
| 22 |
+
uploaded_files_list = []
|
| 23 |
+
for uploaded_file in uploaded_files:
|
| 24 |
+
bytes_data = uploaded_file.read()
|
| 25 |
+
uploaded_files_list.append(File(name=uploaded_file.name, content=bytes_data))
|
| 26 |
+
|
| 27 |
+
# This will create a button
|
| 28 |
+
button_pressed = st.button("Run code interpreter", use_container_width=True)
|
| 29 |
+
|
| 30 |
+
# This will display the images only when the button is pressed
|
| 31 |
+
if button_pressed and input_text != "":
|
| 32 |
+
asyncio.run(get_images(input_text, files=uploaded_files_list))
|