Spaces:
Sleeping
Sleeping
Truong-Phuc Nguyen
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,30 +39,29 @@ btn_save = col_3.button(label=':heavy_check_mark: Save change', use_container_wi
|
|
| 39 |
if len(df) != 0:
|
| 40 |
index = st.session_state.idx
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
if txt_answer.strip() and txt_context.strip():
|
| 47 |
highlighted_context = re.sub(re.escape(txt_answer), "<mark>" + txt_answer + "</mark>", txt_context, flags=re.IGNORECASE)
|
| 48 |
st.markdown(highlighted_context, unsafe_allow_html=True)
|
| 49 |
|
|
|
|
| 50 |
if btn_next:
|
| 51 |
if index < len(df) - 1:
|
| 52 |
st.session_state.idx += 1
|
| 53 |
-
st.rerun()
|
| 54 |
|
| 55 |
if btn_save:
|
| 56 |
st.session_state.df['context'][index] = txt_context
|
| 57 |
st.session_state.df['question'][index] = txt_question
|
| 58 |
st.session_state.df['answer'][index] = txt_answer
|
| 59 |
-
|
| 60 |
-
df = st.session_state.df.copy()
|
| 61 |
-
|
| 62 |
-
csv_file = convert_df(df=df)
|
| 63 |
btn_download = col_4.download_button(data=csv_file, label=':arrow_down_small: Download file', use_container_width=True, file_name="large_df.csv", mime="text/csv")
|
| 64 |
|
| 65 |
if btn_previous:
|
| 66 |
if index > 0:
|
| 67 |
st.session_state.idx -= 1
|
| 68 |
-
st.rerun()
|
|
|
|
| 39 |
if len(df) != 0:
|
| 40 |
index = st.session_state.idx
|
| 41 |
|
| 42 |
+
print(f"Length: {len(st.session_state.df)}")
|
| 43 |
+
txt_context = st.text_area(height=300, label='Your context:', value=st.session_state.df['context'][index])
|
| 44 |
+
txt_question = st.text_area(height=100, label='Your question:', value=st.session_state.df['question'][index])
|
| 45 |
+
txt_answer = st.text_area(height=100, label='Your answer:', value=st.session_state.df['answer'][index])
|
| 46 |
|
| 47 |
if txt_answer.strip() and txt_context.strip():
|
| 48 |
highlighted_context = re.sub(re.escape(txt_answer), "<mark>" + txt_answer + "</mark>", txt_context, flags=re.IGNORECASE)
|
| 49 |
st.markdown(highlighted_context, unsafe_allow_html=True)
|
| 50 |
|
| 51 |
+
|
| 52 |
if btn_next:
|
| 53 |
if index < len(df) - 1:
|
| 54 |
st.session_state.idx += 1
|
| 55 |
+
# st.rerun()
|
| 56 |
|
| 57 |
if btn_save:
|
| 58 |
st.session_state.df['context'][index] = txt_context
|
| 59 |
st.session_state.df['question'][index] = txt_question
|
| 60 |
st.session_state.df['answer'][index] = txt_answer
|
| 61 |
+
csv_file = convert_df(df=st.session_state.df)
|
|
|
|
|
|
|
|
|
|
| 62 |
btn_download = col_4.download_button(data=csv_file, label=':arrow_down_small: Download file', use_container_width=True, file_name="large_df.csv", mime="text/csv")
|
| 63 |
|
| 64 |
if btn_previous:
|
| 65 |
if index > 0:
|
| 66 |
st.session_state.idx -= 1
|
| 67 |
+
# st.rerun()
|