Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -134,15 +134,19 @@ if __name__ == '__main__':
|
|
| 134 |
|
| 135 |
if 'history' not in st.session_state:
|
| 136 |
st.session_state['history'] = []
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
if question is not None and question != "":
|
| 139 |
-
q_relevant = extract_question_type(llm, question)
|
| 140 |
with st.chat_message("user"):
|
| 141 |
st.markdown(question)
|
| 142 |
# Add user message to chat history
|
| 143 |
st.session_state.messages.append({"role": "user", "content": question})
|
| 144 |
|
| 145 |
-
if 'yes' in q_relevant.lower():
|
|
|
|
| 146 |
st.session_state.last_message_failed = False
|
| 147 |
with st.status("Retrieving results..."):
|
| 148 |
#top_table_names = table_search(question, topk=1)['table'].tolist()
|
|
@@ -178,6 +182,7 @@ if __name__ == '__main__':
|
|
| 178 |
response = "\n\n".join(responses)
|
| 179 |
if response == "":
|
| 180 |
response = "Sorry I may not have answer to this question."
|
|
|
|
| 181 |
else:
|
| 182 |
top_table_names = extract_table_name(llm, question) #[extract_table_name(llm, question)]
|
| 183 |
print (top_table_names)
|
|
@@ -210,7 +215,9 @@ if __name__ == '__main__':
|
|
| 210 |
if response == "Sorry I may not have answer to this question.":
|
| 211 |
st.session_state.ask_user_selection = True
|
| 212 |
st.session_state.prev_selection = [mapping[tab] for tab in top_table_names if tab in mapping]
|
| 213 |
-
|
|
|
|
|
|
|
| 214 |
with st.chat_message("assistant"):
|
| 215 |
st.markdown(response)
|
| 216 |
# Add assistant response to chat history
|
|
@@ -289,7 +296,8 @@ if __name__ == '__main__':
|
|
| 289 |
if response == "Sorry I may not have answer to this question.":
|
| 290 |
st.session_state.ask_user_selection = True
|
| 291 |
st.session_state.prev_selection = [mapping[tab] for tab in top_table_names if tab in mapping]
|
| 292 |
-
|
|
|
|
| 293 |
with st.chat_message("assistant"):
|
| 294 |
st.markdown(response)
|
| 295 |
# Add assistant response to chat history
|
|
@@ -332,7 +340,8 @@ if __name__ == '__main__':
|
|
| 332 |
|
| 333 |
st.session_state.ask_user_selection = False
|
| 334 |
st.session_state.prev_selection = []
|
| 335 |
-
|
|
|
|
| 336 |
with st.chat_message("assistant"):
|
| 337 |
st.markdown(response)
|
| 338 |
|
|
|
|
| 134 |
|
| 135 |
if 'history' not in st.session_state:
|
| 136 |
st.session_state['history'] = []
|
| 137 |
+
|
| 138 |
+
if "previous_response" not in st.session_state:
|
| 139 |
+
st.session_state['previous_response'] = ""
|
| 140 |
|
| 141 |
if question is not None and question != "":
|
| 142 |
+
#q_relevant = extract_question_type(llm, question)
|
| 143 |
with st.chat_message("user"):
|
| 144 |
st.markdown(question)
|
| 145 |
# Add user message to chat history
|
| 146 |
st.session_state.messages.append({"role": "user", "content": question})
|
| 147 |
|
| 148 |
+
#if 'yes' in q_relevant.lower():
|
| 149 |
+
if st.session_state['previous_response'] == "Sorry I may not have answer to this question.":
|
| 150 |
st.session_state.last_message_failed = False
|
| 151 |
with st.status("Retrieving results..."):
|
| 152 |
#top_table_names = table_search(question, topk=1)['table'].tolist()
|
|
|
|
| 182 |
response = "\n\n".join(responses)
|
| 183 |
if response == "":
|
| 184 |
response = "Sorry I may not have answer to this question."
|
| 185 |
+
|
| 186 |
else:
|
| 187 |
top_table_names = extract_table_name(llm, question) #[extract_table_name(llm, question)]
|
| 188 |
print (top_table_names)
|
|
|
|
| 215 |
if response == "Sorry I may not have answer to this question.":
|
| 216 |
st.session_state.ask_user_selection = True
|
| 217 |
st.session_state.prev_selection = [mapping[tab] for tab in top_table_names if tab in mapping]
|
| 218 |
+
|
| 219 |
+
st.session_state['previous_response'] = response
|
| 220 |
+
|
| 221 |
with st.chat_message("assistant"):
|
| 222 |
st.markdown(response)
|
| 223 |
# Add assistant response to chat history
|
|
|
|
| 296 |
if response == "Sorry I may not have answer to this question.":
|
| 297 |
st.session_state.ask_user_selection = True
|
| 298 |
st.session_state.prev_selection = [mapping[tab] for tab in top_table_names if tab in mapping]
|
| 299 |
+
|
| 300 |
+
st.session_state['previous_response'] = response
|
| 301 |
with st.chat_message("assistant"):
|
| 302 |
st.markdown(response)
|
| 303 |
# Add assistant response to chat history
|
|
|
|
| 340 |
|
| 341 |
st.session_state.ask_user_selection = False
|
| 342 |
st.session_state.prev_selection = []
|
| 343 |
+
|
| 344 |
+
st.session_state['previous_response'] = response
|
| 345 |
with st.chat_message("assistant"):
|
| 346 |
st.markdown(response)
|
| 347 |
|