XINZHANG-Geotab commited on
Commit
d76808b
·
1 Parent(s): 10b1f37

added modfi

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -6,6 +6,7 @@ from utils import (
6
  )
7
 
8
  import streamlit as st
 
9
  import textwrap as tw
10
  import pandas as pd
11
  from streamlit_extras.stylable_container import stylable_container
@@ -63,7 +64,6 @@ if uploaded_file is not None:
63
 
64
  df.insert(0, 'Select', select_values)
65
  df.at[st.session_state.current_row_index, 'Select'] = True
66
- st.session_state.comments_add = dict((idx, t) for idx, t in enumerate(df["Comment"]))
67
  st.session_state['df'] = df
68
 
69
  df_col, = st.columns(1)
@@ -92,6 +92,12 @@ if uploaded_file is not None:
92
  question = row_data['question']
93
  pred_relevant_choice = row_data['pred_relevant_choice']
94
  correct_response = row_data['correct_response']
 
 
 
 
 
 
95
  first_css = container_regular_css
96
  second_css = container_regular_css
97
  first_color = ':black'
@@ -102,7 +108,7 @@ if uploaded_file is not None:
102
  with st.container(border=True):
103
  # st.write(f"Question: {question}")
104
  st.markdown(f'<p class="question-font">[Q]: {question}</p>', unsafe_allow_html=True)
105
- select_by = st.selectbox("Mark By: ", ["pred_relevant_choice", "correct_response"])
106
  col1_res, col2_res, _ = st.columns([0.2, 0.2, 0.6])
107
  if select_by == 'pred_relevant_choice':
108
  col1_res.write(f":blue[pred_relevant_choice: {pred_relevant_choice}]")
@@ -162,7 +168,12 @@ if uploaded_file is not None:
162
  predicted_sql_text,
163
  language="sql"
164
  )
165
- comment = st.text_area("Comment", value=row_data['Comment'])
 
 
 
 
 
166
 
167
  with st.container():
168
  bcol1, bcol2, _, _, _, _, _, _, _, _ = st.columns(10)
@@ -172,12 +183,14 @@ if uploaded_file is not None:
172
  download = st.button("Download")
173
 
174
  if save:
175
- st.session_state.comments_add[row_index] = comment
176
  st.session_state.df.at[row_index, 'Comment'] = comment
 
 
177
  df = st.session_state.df.drop('Select', axis=1)
178
  df.to_csv('modified.csv', index=False)
179
- # st.rerun()
180
-
181
  if download:
182
  with open('modified.csv') as f:
183
  st.download_button('Download modified CSV', f, file_name='modified.csv')
 
6
  )
7
 
8
  import streamlit as st
9
+ import json
10
  import textwrap as tw
11
  import pandas as pd
12
  from streamlit_extras.stylable_container import stylable_container
 
64
 
65
  df.insert(0, 'Select', select_values)
66
  df.at[st.session_state.current_row_index, 'Select'] = True
 
67
  st.session_state['df'] = df
68
 
69
  df_col, = st.columns(1)
 
92
  question = row_data['question']
93
  pred_relevant_choice = row_data['pred_relevant_choice']
94
  correct_response = row_data['correct_response']
95
+ relative_relevancy = json.loads(row_data['relative_relevancy'])
96
+ reason = relative_relevancy['reason']
97
+ most_relevant = relative_relevancy['most_relevant']
98
+ options=['first', 'second', 'both']
99
+ default_index = options.index(most_relevant)
100
+ default_comment = row_data['Comment']
101
  first_css = container_regular_css
102
  second_css = container_regular_css
103
  first_color = ':black'
 
108
  with st.container(border=True):
109
  # st.write(f"Question: {question}")
110
  st.markdown(f'<p class="question-font">[Q]: {question}</p>', unsafe_allow_html=True)
111
+ select_by = st.selectbox("Mark By: ", ["pred_relevant_choice", "correct_response"], key='mark_by_dropdown')
112
  col1_res, col2_res, _ = st.columns([0.2, 0.2, 0.6])
113
  if select_by == 'pred_relevant_choice':
114
  col1_res.write(f":blue[pred_relevant_choice: {pred_relevant_choice}]")
 
168
  predicted_sql_text,
169
  language="sql"
170
  )
171
+ col1_comment, col2_comment = st.columns([1, 1])
172
+ with col1_comment:
173
+ select_most_relevant = st.selectbox("most_relevant", options=options, index=default_index, key='most_relevant_drop_down')
174
+ reason_box = st.text_area("reason", value=reason, key='reason_text')
175
+ with col2_comment:
176
+ comment = st.text_area("Comment", value=default_comment, key='comment_text')
177
 
178
  with st.container():
179
  bcol1, bcol2, _, _, _, _, _, _, _, _ = st.columns(10)
 
183
  download = st.button("Download")
184
 
185
  if save:
186
+ updated_relative_relevancy = json.dumps({'most_relevant': select_most_relevant, "reason": reason_box})
187
  st.session_state.df.at[row_index, 'Comment'] = comment
188
+ st.session_state.df.at[row_index, 'relative_relevancy'] = updated_relative_relevancy
189
+ st.session_state.df.at[row_index, 'correct_response'] = select_most_relevant
190
  df = st.session_state.df.drop('Select', axis=1)
191
  df.to_csv('modified.csv', index=False)
192
+ st.rerun()
193
+
194
  if download:
195
  with open('modified.csv') as f:
196
  st.download_button('Download modified CSV', f, file_name='modified.csv')