Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# Title
|
5 |
+
st.title("Q&A Evaluation Tool")
|
6 |
+
|
7 |
+
# Upload the dataset
|
8 |
+
@st.cache_data
|
9 |
+
def load_data(file_path):
|
10 |
+
return pd.read_excel(file_path)
|
11 |
+
|
12 |
+
# File upload section
|
13 |
+
uploaded_file = st.file_uploader("Upload the Q&A Excel File", type=["xlsx"])
|
14 |
+
|
15 |
+
if uploaded_file:
|
16 |
+
# Load data
|
17 |
+
data = load_data(uploaded_file)
|
18 |
+
|
19 |
+
# Add columns for evaluation if not present
|
20 |
+
if "Rating" not in data.columns:
|
21 |
+
data["Rating"] = ""
|
22 |
+
if "Comments" not in data.columns:
|
23 |
+
data["Comments"] = ""
|
24 |
+
|
25 |
+
# Initialize session state for tracking progress
|
26 |
+
if "current_index" not in st.session_state:
|
27 |
+
st.session_state.current_index = 0
|
28 |
+
|
29 |
+
# Display current question-answer pair
|
30 |
+
idx = st.session_state.current_index
|
31 |
+
if idx < len(data):
|
32 |
+
st.subheader(f"Question {idx + 1}:")
|
33 |
+
st.write(data.loc[idx, "Question"])
|
34 |
+
|
35 |
+
st.subheader("Generated Answer:")
|
36 |
+
st.write(data.loc[idx, "Generated Answer"])
|
37 |
+
|
38 |
+
# Rating input
|
39 |
+
rating = st.slider("Rate the answer (1 = Poor, 5 = Excellent)", 1, 5, step=1)
|
40 |
+
comment = st.text_area("Add any comments or suggestions")
|
41 |
+
|
42 |
+
# Save feedback
|
43 |
+
if st.button("Submit Feedback"):
|
44 |
+
data.at[idx, "Rating"] = rating
|
45 |
+
data.at[idx, "Comments"] = comment
|
46 |
+
st.session_state.current_index += 1
|
47 |
+
|
48 |
+
# Save the updated dataset
|
49 |
+
data.to_excel("evaluated_data.xlsx", index=False)
|
50 |
+
|
51 |
+
# Confirmation and next question
|
52 |
+
st.success("Feedback submitted!")
|
53 |
+
st.experimental_rerun()
|
54 |
+
else:
|
55 |
+
st.write("You have completed the evaluation. Thank you!")
|
56 |
+
|
57 |
+
# Download the evaluated file
|
58 |
+
with open("evaluated_data.xlsx", "rb") as f:
|
59 |
+
st.download_button(
|
60 |
+
"Download Evaluated Data",
|
61 |
+
f,
|
62 |
+
file_name="evaluated_data.xlsx",
|
63 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
64 |
+
)
|
65 |
+
|
66 |
+
else:
|
67 |
+
st.info("Please upload an Excel file to get started.")
|