File size: 2,900 Bytes
b8b0b89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1064d9
 
b8b0b89
032b798
d1064d9
 
b8b0b89
d920a9f
b8b0b89
d1064d9
 
b8b0b89
d1064d9
b8b0b89
d1064d9
 
 
 
 
 
 
 
 
 
 
 
 
 
b8b0b89
d1064d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8b0b89
d1064d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8b0b89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

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)