File size: 3,546 Bytes
4dd9ebd 465b890 ce40f85 2fd0e0b 32c0f7f 6882039 62fc389 6882039 62fc389 56f2c57 eb6daca 1bdc7fe 62fc389 bfe8a00 b1d5623 b9aaab1 b1d5623 c883735 b1d5623 c883735 b1d5623 c883735 b1d5623 c883735 b1d5623 |
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 82 83 84 85 86 87 88 89 90 91 92 |
# app_agent_config.py
import streamlit as st
from tool_loader import ToolLoader
from tool_config import tool_names
from logger import log_enabled
from PIL import Image
import numpy as np
class AgentConfig:
def __init__(self):
self.tool_checkboxes = []
self.url_endpoint = ""
self.image = []
self.document = ""
self.log_enabled = False
self.context = ""
self.tool_loader = ToolLoader(tool_names)
def configure(self):
st.markdown("Change the agent's configuration here.")
self.url_endpoint = st.selectbox("Select Inference URL", [
"https://api-inference.huggingface.co/models/bigcode/starcoder",
"https://api-inference.huggingface.co/models/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
"https://api-inference.huggingface.co/models/gpt2"
])
tool_loader = ToolLoader(tool_names)
self.log_enabled = st.checkbox("Enable Logging")
self.tool_checkboxes = [st.checkbox(f"{tool.name} --- {tool.description} ") for tool in tool_loader.tools]
def content_and_context(self):
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:
pdf_document = uploaded_file.getvalue()
agent_config.document = pdf_document
st.write(pdf_document)
uploaded_txt_file = st.file_uploader("Choose a txt", type='txt')
if uploaded_txt_file is not None:
# To read file as bytes:
txt_document = uploaded_txt_file.getvalue()
agent_config.document = txt_document
st.write(txt_document)
uploaded_csv_file = st.file_uploader("Choose a csv", type='csv')
if uploaded_csv_file is not None:
# To read file as bytes:
csv_document = uploaded_csv_file.getvalue()
agent_config.document = csv_document
st.write(csv_document)
uploaded_csv_file = st.file_uploader("Choose audio", type='wav')
if uploaded_csv_file is not None:
# To read file as bytes:
csv_document = uploaded_csv_file.getvalue()
agent_config.document = csv_document
st.write(csv_document)
uploaded_csv_file = st.file_uploader("Choose video", type='avi')
if uploaded_csv_file is not None:
# To read file as bytes:
csv_document = uploaded_csv_file.getvalue()
agent_config.document = csv_document
st.write(csv_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)
|