Spaces:
Sleeping
Sleeping
sdripie
commited on
Commit
Β·
5c8ed53
1
Parent(s):
bea7d89
edit interface
Browse files
app.py
CHANGED
|
@@ -15,39 +15,41 @@ st.set_page_config(page_title="Table Question Answering", layout="wide")
|
|
| 15 |
st.title("π Table Question Answering")
|
| 16 |
st.write("""
|
| 17 |
Welcome to the **Table Question Answering** app!
|
| 18 |
-
You can upload
|
| 19 |
The model will analyze the table and provide accurate answers.
|
| 20 |
""")
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
table = pd.
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
st.
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
#
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
st.
|
| 53 |
-
|
|
|
|
|
|
|
|
|
| 15 |
st.title("π Table Question Answering")
|
| 16 |
st.write("""
|
| 17 |
Welcome to the **Table Question Answering** app!
|
| 18 |
+
You can upload your own table and ask questions about it.
|
| 19 |
The model will analyze the table and provide accurate answers.
|
| 20 |
""")
|
| 21 |
|
| 22 |
+
# Step 1: Table input
|
| 23 |
+
st.header("π Step 1: Upload your table")
|
| 24 |
+
# Option to upload a excel file
|
| 25 |
+
uploaded_file = st.file_uploader("Upload your Excel file:", type=["xlsx"])
|
| 26 |
+
if uploaded_file is not None:
|
| 27 |
+
try:
|
| 28 |
+
table = pd.read_excel(uploaded_file)
|
| 29 |
+
st.success("Table uploaded successfully!")
|
| 30 |
+
st.write("### Preview of Uploaded Table:")
|
| 31 |
+
st.dataframe(table, use_container_width=True)
|
| 32 |
+
except Exception as e:
|
| 33 |
+
st.error(f"Error reading the file: {e}")
|
| 34 |
+
table = None
|
| 35 |
+
else:
|
| 36 |
+
st.info("Please upload an Excel file to proceed.")
|
| 37 |
+
table = None
|
| 38 |
+
|
| 39 |
+
st.divider()
|
| 40 |
+
st.header("β Step 2: Ask a Question")
|
| 41 |
+
query = st.text_input("Ask a question about the table:")
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
st.divider()
|
| 45 |
+
if st.button("π Get Answer"):
|
| 46 |
+
if table is not None and query:
|
| 47 |
+
table = table.astype(str) # Ensure all values are strings
|
| 48 |
+
result = pipe(table=table, query=query)
|
| 49 |
+
st.success("Answer:")
|
| 50 |
+
st.markdown(f"### {result['answer']}")
|
| 51 |
+
else:
|
| 52 |
+
st.warning("Please upload a table and enter a question before clicking 'Get Answer'.")
|
| 53 |
+
|
| 54 |
+
st.divider()
|
| 55 |
+
st.markdown("**β€οΈ**")
|