Update app_agent_config.py
Browse files- app_agent_config.py +55 -56
app_agent_config.py
CHANGED
|
@@ -7,7 +7,6 @@ from logger import log_enabled
|
|
| 7 |
from PIL import Image
|
| 8 |
import numpy as np
|
| 9 |
|
| 10 |
-
|
| 11 |
class AgentConfig:
|
| 12 |
def __init__(self):
|
| 13 |
self.tool_checkboxes = []
|
|
@@ -30,63 +29,63 @@ class AgentConfig:
|
|
| 30 |
self.tool_checkboxes = [st.checkbox(f"{tool.name} --- {tool.description} ") for tool in tool_loader.tools]
|
| 31 |
|
| 32 |
def content_and_context(self):
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
uploaded_txt_file = st.file_uploader("Choose a txt", type='txt')
|
| 54 |
-
if uploaded_txt_file is not None:
|
| 55 |
-
# To read file as bytes:
|
| 56 |
-
txt_document = uploaded_txt_file.getvalue()
|
| 57 |
-
agent_config.document = txt_document
|
| 58 |
-
st.write(txt_document)
|
| 59 |
-
|
| 60 |
-
uploaded_csv_file = st.file_uploader("Choose a csv", type='csv')
|
| 61 |
-
if uploaded_csv_file is not None:
|
| 62 |
-
# To read file as bytes:
|
| 63 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 64 |
-
agent_config.document = csv_document
|
| 65 |
-
st.write(csv_document)
|
| 66 |
-
|
| 67 |
-
uploaded_csv_file = st.file_uploader("Choose audio", type='wav')
|
| 68 |
-
if uploaded_csv_file is not None:
|
| 69 |
-
# To read file as bytes:
|
| 70 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 71 |
-
agent_config.document = csv_document
|
| 72 |
-
st.write(csv_document)
|
| 73 |
-
|
| 74 |
-
uploaded_csv_file = st.file_uploader("Choose video", type='avi')
|
| 75 |
-
if uploaded_csv_file is not None:
|
| 76 |
-
# To read file as bytes:
|
| 77 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 78 |
-
agent_config.document = csv_document
|
| 79 |
-
st.write(csv_document)
|
| 80 |
-
|
| 81 |
-
# To convert to a string based IO:
|
| 82 |
-
#stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
| 83 |
-
#st.write(stringio)
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
|
|
|
| 7 |
from PIL import Image
|
| 8 |
import numpy as np
|
| 9 |
|
|
|
|
| 10 |
class AgentConfig:
|
| 11 |
def __init__(self):
|
| 12 |
self.tool_checkboxes = []
|
|
|
|
| 29 |
self.tool_checkboxes = [st.checkbox(f"{tool.name} --- {tool.description} ") for tool in tool_loader.tools]
|
| 30 |
|
| 31 |
def content_and_context(self):
|
| 32 |
+
agent_config.context = st.text_area("Context")
|
| 33 |
|
| 34 |
+
agent_config.image = st.camera_input("Take a picture")
|
| 35 |
|
| 36 |
+
img_file_buffer = st.file_uploader('Upload a PNG image', type='png')
|
| 37 |
+
|
| 38 |
+
if img_file_buffer is not None:
|
| 39 |
+
image_raw = Image.open(img_file_buffer)
|
| 40 |
+
#global image
|
| 41 |
+
agent_config.image = np.array(image_raw)
|
| 42 |
+
########
|
| 43 |
+
st.image(agent_config.image)
|
| 44 |
+
|
| 45 |
+
uploaded_file = st.file_uploader("Choose a pdf", type='pdf')
|
| 46 |
+
if uploaded_file is not None:
|
| 47 |
+
# To read file as bytes:
|
| 48 |
+
pdf_document = uploaded_file.getvalue()
|
| 49 |
+
agent_config.document = pdf_document
|
| 50 |
+
st.write(pdf_document)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
uploaded_txt_file = st.file_uploader("Choose a txt", type='txt')
|
| 53 |
+
if uploaded_txt_file is not None:
|
| 54 |
+
# To read file as bytes:
|
| 55 |
+
txt_document = uploaded_txt_file.getvalue()
|
| 56 |
+
agent_config.document = txt_document
|
| 57 |
+
st.write(txt_document)
|
| 58 |
+
|
| 59 |
+
uploaded_csv_file = st.file_uploader("Choose a csv", type='csv')
|
| 60 |
+
if uploaded_csv_file is not None:
|
| 61 |
+
# To read file as bytes:
|
| 62 |
+
csv_document = uploaded_csv_file.getvalue()
|
| 63 |
+
agent_config.document = csv_document
|
| 64 |
+
st.write(csv_document)
|
| 65 |
+
|
| 66 |
+
uploaded_csv_file = st.file_uploader("Choose audio", type='wav')
|
| 67 |
+
if uploaded_csv_file is not None:
|
| 68 |
+
# To read file as bytes:
|
| 69 |
+
csv_document = uploaded_csv_file.getvalue()
|
| 70 |
+
agent_config.document = csv_document
|
| 71 |
+
st.write(csv_document)
|
| 72 |
|
| 73 |
+
uploaded_csv_file = st.file_uploader("Choose video", type='avi')
|
| 74 |
+
if uploaded_csv_file is not None:
|
| 75 |
+
# To read file as bytes:
|
| 76 |
+
csv_document = uploaded_csv_file.getvalue()
|
| 77 |
+
agent_config.document = csv_document
|
| 78 |
+
st.write(csv_document)
|
| 79 |
+
|
| 80 |
+
# To convert to a string based IO:
|
| 81 |
+
#stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
| 82 |
+
#st.write(stringio)
|
| 83 |
+
|
| 84 |
+
# To read file as string:
|
| 85 |
+
#string_data = stringio.read()
|
| 86 |
+
#st.write(string_data)
|
| 87 |
+
|
| 88 |
+
# Can be used wherever a "file-like" object is accepted:
|
| 89 |
+
dataframe = pd.read_csv(uploaded_file)
|
| 90 |
+
st.write(dataframe)
|
| 91 |
|