import streamlit as st from PIL import Image import numpy as np import pandas as pd def app_sidebar(controller): with st.sidebar: st.header("Set Tools and Option. ") with st.expander("Configure the agent and tools"): configure(controller.agent_config) with st.expander("Set the Content and Context"): content_and_context(controller.agent_config) def configure(agent_config): st.markdown("Change the agent's configuration here.") agent_config.url_endpoint = st.selectbox("Select Inference URL", agent_config.agent_urls) agent_config.log_enabled = st.checkbox("Enable Logging") agent_config.s_tool_checkboxes = [st.checkbox(f"{tool.name} --- {tool.description} ") for tool in agent_config.tool_loader.tools] def content_and_context(agent_config): agent_config.context = st.text_area("Context") agent_config.image = st.camera_input("Take a picture") img_file_buffer = st.file_uploader('Upload a PNG image', type='png') if img_file_buffer is not None: image_raw = Image.open(img_file_buffer) #global image agent_config.image = np.array(image_raw) ######## st.image(agent_config.image) uploaded_file = st.file_uploader("Choose a pdf", type='pdf') if uploaded_file is not None: # To read file as bytes: agent_config.document = uploaded_file.getvalue() st.write(agent_config.document) uploaded_txt_file = st.file_uploader("Choose a txt", type='txt') if uploaded_txt_file is not None: # To read file as bytes: agent_config.document = uploaded_txt_file.getvalue() st.write(agent_config.document) uploaded_csv_file = st.file_uploader("Choose a csv", type='csv') if uploaded_csv_file is not None: # To read file as bytes: agent_config.document = uploaded_csv_file.getvalue() st.write(agent_config.document) uploaded_csv_file = st.file_uploader("Choose audio", type='wav') if uploaded_csv_file is not None: # To read file as bytes: agent_config.document = uploaded_csv_file.getvalue() st.write(agent_config.document) uploaded_csv_file = st.file_uploader("Choose video", type='avi') if uploaded_csv_file is not None: # To read file as bytes: agent_config.document = uploaded_csv_file.getvalue() st.write(agent_config.document) # To convert to a string based IO: #stringio = StringIO(uploaded_file.getvalue().decode("utf-8")) #st.write(stringio) # To read file as string: #string_data = stringio.read() #st.write(string_data) # Can be used wherever a "file-like" object is accepted: dataframe = pd.read_csv(uploaded_file) st.write(dataframe)