Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,30 @@ def generate_summary(contract_text):
|
|
12 |
|
13 |
# Function to handle feedback and store it in a CSV file
|
14 |
def handle_feedback(feedback_data):
|
15 |
-
feedback_df = pd.DataFrame(feedback_data, columns=['Contract', 'Summary', '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
feedback_df.to_csv('feedback.csv', mode='a', index=False, header=not st.session_state.feedback_csv_exists)
|
17 |
st.session_state.feedback_csv_exists = True
|
18 |
|
|
|
|
|
|
|
|
|
19 |
# Main Streamlit app
|
20 |
def main():
|
21 |
st.title("Legal Contract Summarizer with Feedback")
|
@@ -31,11 +51,11 @@ def main():
|
|
31 |
|
32 |
# Feedback section
|
33 |
st.subheader("Feedback:")
|
34 |
-
thumbs_up = st.button("π
|
35 |
-
thumbs_down = st.button("π
|
36 |
|
37 |
-
chosen =
|
38 |
-
rejected =
|
39 |
|
40 |
feedback_data.append((contract_text, summary, chosen, rejected))
|
41 |
|
|
|
12 |
|
13 |
# Function to handle feedback and store it in a CSV file
|
14 |
def handle_feedback(feedback_data):
|
15 |
+
feedback_df = pd.DataFrame(feedback_data, columns=['Contract', 'Summary', 'π', 'π'])
|
16 |
+
|
17 |
+
# Save the dataframe to a temporary CSV file
|
18 |
+
temp_csv_path = 'temp_feedback.csv'
|
19 |
+
feedback_df.to_csv(temp_csv_path, index=False, header=not st.session_state.feedback_csv_exists)
|
20 |
+
|
21 |
+
# Display a download link for the user
|
22 |
+
st.download_button(
|
23 |
+
label="Download Feedback CSV",
|
24 |
+
data=temp_csv_path,
|
25 |
+
key="download_feedback_csv",
|
26 |
+
on_click=download_feedback_csv,
|
27 |
+
args=(temp_csv_path,),
|
28 |
+
help="Click to download the feedback CSV file."
|
29 |
+
)
|
30 |
+
|
31 |
+
# Append feedback to the main CSV file
|
32 |
feedback_df.to_csv('feedback.csv', mode='a', index=False, header=not st.session_state.feedback_csv_exists)
|
33 |
st.session_state.feedback_csv_exists = True
|
34 |
|
35 |
+
# Callback function for download button
|
36 |
+
def download_feedback_csv(file_path):
|
37 |
+
st.markdown(f"Download [Feedback CSV File]({file_path})", unsafe_allow_html=True)
|
38 |
+
|
39 |
# Main Streamlit app
|
40 |
def main():
|
41 |
st.title("Legal Contract Summarizer with Feedback")
|
|
|
51 |
|
52 |
# Feedback section
|
53 |
st.subheader("Feedback:")
|
54 |
+
thumbs_up = st.button("π")
|
55 |
+
thumbs_down = st.button("π")
|
56 |
|
57 |
+
chosen = "π" if thumbs_up else None
|
58 |
+
rejected = "π" if thumbs_down else None
|
59 |
|
60 |
feedback_data.append((contract_text, summary, chosen, rejected))
|
61 |
|