ashmib commited on
Commit
a2dd0df
·
verified ·
1 Parent(s): a889d31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -59
app.py CHANGED
@@ -4,64 +4,57 @@ import streamlit as st
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.")
 
 
 
 
 
 
 
 
 
 
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
+ )