File size: 4,454 Bytes
fdfb0c4 cca6750 1c5a6c6 b658652 365d369 934d9a2 17e8776 1c5a6c6 7118235 cddf298 58bb7f3 e8f0d97 ecfa0bf d2826a9 2a2c3ec 8f2a15c ecfa0bf d9fa708 2a2c3ec 8f2a15c 2a2c3ec 8f2a15c de95d73 8d7bc1b ecfa0bf 8d7bc1b 8f2a15c 8d7bc1b ecfa0bf 8d7bc1b ecfa0bf 8d7bc1b ecfa0bf 8d7bc1b 4201209 8d7bc1b 4201209 8d7bc1b 8f2a15c 08f300b d2826a9 944514e 2a2c3ec de95d73 944514e 1466171 346bac9 f033509 1c5a6c6 f033509 2a2c3ec 346bac9 944514e 2a2c3ec 1c5a6c6 de95d73 1c5a6c6 944514e c00873c 1c5a6c6 934d9a2 365d369 |
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
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()
# 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. CustomTransformers can do anything \nπ€ͺπ€ππ€π€ͺ.")
#######
import pandas as pd
from io import StringIO
with st.sidebar:
with st.expander("Configure the agent and activate tools"):
st.header("Set Tools and Option. Context and Content.")
agent_config.configure()
with st.expander("Set content and context"):
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)
# Create a page with tabs
tabs = st.tabs(["Chat","User Description"])
#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("Start to chat. e.g. Generate an image of a boat. This will make the agent use the tool text2image to generate an image. Set content, context, Inference URL , tools and logging in the sidebar.")
# Tab 3: User Description
with tabs[1]:
#
app_user_desc()
# Tab 4: Developers
#with tabs[3]:
# app_dev_desc()
#app_chat()
app_chat(agent_config) |