Update app.py
Browse files
app.py
CHANGED
|
@@ -22,11 +22,6 @@ agent_config = AgentConfig()
|
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
-
st.title("Hugging Face Agent and Tools")
|
| 26 |
-
|
| 27 |
-
## LB https://huggingface.co/spaces/qiantong-xu/toolbench-leaderboard
|
| 28 |
-
|
| 29 |
-
st.markdown("Welcome to the Hugging Face Agent and Tools app! This app allows you to interact with various tools using the Hugging Face Inference API. CustomTransformers can do anything \nπ€ͺπ€ππ€π€ͺ.")
|
| 30 |
|
| 31 |
#######
|
| 32 |
|
|
@@ -42,71 +37,19 @@ with st.sidebar:
|
|
| 42 |
|
| 43 |
with st.expander("Set Content and Context"):
|
| 44 |
|
| 45 |
-
agent_config.
|
| 46 |
-
|
| 47 |
-
agent_config.image = st.camera_input("Take a picture")
|
| 48 |
-
|
| 49 |
-
img_file_buffer = st.file_uploader('Upload a PNG image', type='png')
|
| 50 |
-
|
| 51 |
-
if img_file_buffer is not None:
|
| 52 |
-
image_raw = Image.open(img_file_buffer)
|
| 53 |
-
#global image
|
| 54 |
-
agent_config.image = np.array(image_raw)
|
| 55 |
-
########
|
| 56 |
-
st.image(agent_config.image)
|
| 57 |
-
|
| 58 |
-
uploaded_file = st.file_uploader("Choose a pdf", type='pdf')
|
| 59 |
-
if uploaded_file is not None:
|
| 60 |
-
# To read file as bytes:
|
| 61 |
-
pdf_document = uploaded_file.getvalue()
|
| 62 |
-
agent_config.document = pdf_document
|
| 63 |
-
st.write(pdf_document)
|
| 64 |
-
|
| 65 |
-
uploaded_txt_file = st.file_uploader("Choose a txt", type='txt')
|
| 66 |
-
if uploaded_txt_file is not None:
|
| 67 |
-
# To read file as bytes:
|
| 68 |
-
txt_document = uploaded_txt_file.getvalue()
|
| 69 |
-
agent_config.document = txt_document
|
| 70 |
-
st.write(txt_document)
|
| 71 |
-
|
| 72 |
-
uploaded_csv_file = st.file_uploader("Choose a csv", type='csv')
|
| 73 |
-
if uploaded_csv_file is not None:
|
| 74 |
-
# To read file as bytes:
|
| 75 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 76 |
-
agent_config.document = csv_document
|
| 77 |
-
st.write(csv_document)
|
| 78 |
-
|
| 79 |
-
uploaded_csv_file = st.file_uploader("Choose audio", type='wav')
|
| 80 |
-
if uploaded_csv_file is not None:
|
| 81 |
-
# To read file as bytes:
|
| 82 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 83 |
-
agent_config.document = csv_document
|
| 84 |
-
st.write(csv_document)
|
| 85 |
-
|
| 86 |
-
uploaded_csv_file = st.file_uploader("Choose video", type='avi')
|
| 87 |
-
if uploaded_csv_file is not None:
|
| 88 |
-
# To read file as bytes:
|
| 89 |
-
csv_document = uploaded_csv_file.getvalue()
|
| 90 |
-
agent_config.document = csv_document
|
| 91 |
-
st.write(csv_document)
|
| 92 |
-
|
| 93 |
-
# To convert to a string based IO:
|
| 94 |
-
#stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
| 95 |
-
#st.write(stringio)
|
| 96 |
-
|
| 97 |
-
# To read file as string:
|
| 98 |
-
#string_data = stringio.read()
|
| 99 |
-
#st.write(string_data)
|
| 100 |
-
|
| 101 |
-
# Can be used wherever a "file-like" object is accepted:
|
| 102 |
-
dataframe = pd.read_csv(uploaded_file)
|
| 103 |
-
st.write(dataframe)
|
| 104 |
-
|
| 105 |
# Create a page with tabs
|
| 106 |
tabs = st.tabs(["Chat","User Description"])
|
| 107 |
|
| 108 |
with tabs[0]:
|
| 109 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
with tabs[1]:
|
| 112 |
app_user_desc()
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
#######
|
| 27 |
|
|
|
|
| 37 |
|
| 38 |
with st.expander("Set Content and Context"):
|
| 39 |
|
| 40 |
+
agent_config.content_and_Context()
|
| 41 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Create a page with tabs
|
| 43 |
tabs = st.tabs(["Chat","User Description"])
|
| 44 |
|
| 45 |
with tabs[0]:
|
| 46 |
+
st.title("Hugging Face Agent and Tools")
|
| 47 |
+
|
| 48 |
+
## LB https://huggingface.co/spaces/qiantong-xu/toolbench-leaderboard
|
| 49 |
+
|
| 50 |
+
st.markdown("Welcome to the Hugging Face Agent and Tools app! This app allows you to interact with various tools using the Hugging Face Inference API. CustomTransformers can do anything \nπ€ͺπ€ππ€π€ͺ.")
|
| 51 |
+
|
| 52 |
+
#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.")
|
| 53 |
|
| 54 |
with tabs[1]:
|
| 55 |
app_user_desc()
|