Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,64 +4,57 @@ import streamlit as st
|
|
4 |
# Title
|
5 |
st.title("Q&A Evaluation Tool")
|
6 |
|
7 |
-
#
|
8 |
@st.cache_data
|
9 |
-
def load_data(
|
10 |
-
return pd.
|
11 |
-
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
if
|
16 |
-
|
17 |
-
data =
|
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 |
-
# 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# Title
|
5 |
st.title("Q&A Evaluation Tool")
|
6 |
|
7 |
+
# Load the dataset from the repository
|
8 |
@st.cache_data
|
9 |
+
def load_data():
|
10 |
+
return pd.read_csv("dummy_qa_data.csv")
|
11 |
+
|
12 |
+
# Load data
|
13 |
+
data = load_data()
|
14 |
+
|
15 |
+
# Add columns for evaluation if not present
|
16 |
+
if "Rating" not in data.columns:
|
17 |
+
data["Rating"] = ""
|
18 |
+
if "Comments" not in data.columns:
|
19 |
+
data["Comments"] = ""
|
20 |
+
|
21 |
+
# Initialize session state for tracking progress
|
22 |
+
if "current_index" not in st.session_state:
|
23 |
+
st.session_state.current_index = 0
|
24 |
+
|
25 |
+
# Display current question-answer pair
|
26 |
+
idx = st.session_state.current_index
|
27 |
+
if idx < len(data):
|
28 |
+
st.subheader(f"Question {idx + 1}:")
|
29 |
+
st.write(data.loc[idx, "Question"])
|
30 |
+
|
31 |
+
st.subheader("Generated Answer:")
|
32 |
+
st.write(data.loc[idx, "Generated Answer"])
|
33 |
+
|
34 |
+
# Rating input
|
35 |
+
rating = st.slider("Rate the answer (1 = Poor, 5 = Excellent)", 1, 5, step=1)
|
36 |
+
comment = st.text_area("Add any comments or suggestions")
|
37 |
+
|
38 |
+
# Save feedback
|
39 |
+
if st.button("Submit Feedback"):
|
40 |
+
data.at[idx, "Rating"] = rating
|
41 |
+
data.at[idx, "Comments"] = comment
|
42 |
+
st.session_state.current_index += 1
|
43 |
+
|
44 |
+
# Save the updated dataset
|
45 |
+
data.to_csv("evaluated_data.csv", index=False)
|
46 |
+
|
47 |
+
# Confirmation and next question
|
48 |
+
st.success("Feedback submitted!")
|
49 |
+
st.experimental_rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
else:
|
51 |
+
st.write("You have completed the evaluation. Thank you!")
|
52 |
+
|
53 |
+
# Download the evaluated file
|
54 |
+
with open("evaluated_data.csv", "rb") as f:
|
55 |
+
st.download_button(
|
56 |
+
"Download Evaluated Data",
|
57 |
+
f,
|
58 |
+
file_name="evaluated_data.csv",
|
59 |
+
mime="text/csv",
|
60 |
+
)
|