import streamlit as st from PIL import Image from tool_loader import ToolLoader from app_user_desc import app_user_desc from app_dev_desc import app_dev_desc from logger import log_response from logger import log_enabled from app_chat import app_chat import numpy as np from app_agent_config import AgentConfig # Create an instance of AgentConfig agent_config = AgentConfig() global image # Declare global variable st.set_page_config( page_title="Transformers can realy do anything...", page_icon="👋", ) st.title("Hugging Face Agent and tools") ## LB https://huggingface.co/spaces/qiantong-xu/toolbench-leaderboard st.markdown("Welcome to the Hugging Face Agent and Tools app! This app allows you to interact with various tools using the Hugging Face API.") ####### import pandas as pd from io import StringIO with st.sidebar: with st.expander("See explanation"): 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 image = np.array(image_raw) ######## st.image(image) uploaded_file = st.file_uploader("Choose a file", type='pdf') if uploaded_file is not None: # To read file as bytes: pdf_document = uploaded_file.getvalue() global document document = pdf_document st.write(pdf_document) uploaded_txt_file = st.file_uploader("Choose a file", type='txt') if uploaded_txt_file is not None: # To read file as bytes: txt_document = uploaded_txt_file.getvalue() document = txt_document st.write(txt_document) uploaded_csv_file = st.file_uploader("Choose a file", type='csv') if uploaded_csv_file is not None: # To read file as bytes: csv_document = uploaded_csv_file.getvalue() 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) # Create a page with tabs tabs = st.tabs(["Chat", "URL, Tools and logging", "User Description", "Developers"]) # Tab 1: Chat with tabs[0]: # Code for URL and Tools checkboxes #chat_description() # Examples for the user perspective st.markdown("Stat to chat. e.g. Generate an image of a boat. This will make the agent use the tool text2image to generate an image.") # Tab 2: URL and Tools with tabs[1]: # agent_config.configure() # Tab 3: User Description #with tabs[2]: # # app_user_desc() # Tab 4: Developers #with tabs[3]: # app_dev_desc() #app_chat() app_chat(agent_config)