Carlosito16 commited on
Commit
affd12c
1 Parent(s): d0c7993

log saving and pad removal

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -86,13 +86,13 @@ def retrieve_document(query_input):
86
  def retrieve_answer(query_input):
87
  prompt_answer= query_input + " " + "Try to elaborate as much as you can."
88
  answer = qa_retriever.run(prompt_answer)
89
- output = st.text_area(label="Retrieved documents", value=answer)
90
 
91
  st.markdown('---')
92
  score = st.radio(label = 'please select the rating score for overall satifaction and helpfullness of the bot answer', options=[0, 1,2,3,4,5], horizontal=True,
93
  on_change=update_worksheet_qa, key='rating')
94
 
95
- return answer
96
 
97
  # def update_score():
98
  # st.session_state.session_rating = st.session_state.rating
@@ -101,8 +101,13 @@ def retrieve_answer(query_input):
101
  def update_worksheet_qa():
102
  st.session_state.session_rating = st.session_state.rating
103
  #This if helps validate the initiated rating, if 0, then the google sheet would not be updated
 
104
  if st.session_state.session_rating == 0:
105
- pass
 
 
 
 
106
  else:
107
  worksheet_qa.append_row([st.session_state.history[-1]['timestamp'].strftime(datetime_format),
108
  st.session_state.history[-1]['question'],
 
86
  def retrieve_answer(query_input):
87
  prompt_answer= query_input + " " + "Try to elaborate as much as you can."
88
  answer = qa_retriever.run(prompt_answer)
89
+ output = st.text_area(label="Retrieved documents", value=answer[6:]) #this positional slicing helps remove "<pad> " at the beginning
90
 
91
  st.markdown('---')
92
  score = st.radio(label = 'please select the rating score for overall satifaction and helpfullness of the bot answer', options=[0, 1,2,3,4,5], horizontal=True,
93
  on_change=update_worksheet_qa, key='rating')
94
 
95
+ return answer[6:] #this positional slicing helps remove "<pad> " at the beginning
96
 
97
  # def update_score():
98
  # st.session_state.session_rating = st.session_state.rating
 
101
  def update_worksheet_qa():
102
  st.session_state.session_rating = st.session_state.rating
103
  #This if helps validate the initiated rating, if 0, then the google sheet would not be updated
104
+ #(edited) now even with the score of 0, we still want to store the log because some users do not give the score to complete the logging
105
  if st.session_state.session_rating == 0:
106
+ worksheet_qa.append_row([st.session_state.history[-1]['timestamp'].strftime(datetime_format),
107
+ st.session_state.history[-1]['question'],
108
+ st.session_state.history[-1]['generated_answer'],
109
+ st.session_state.session_rating
110
+ ])
111
  else:
112
  worksheet_qa.append_row([st.session_state.history[-1]['timestamp'].strftime(datetime_format),
113
  st.session_state.history[-1]['question'],