mikepastor11 commited on
Commit
34ff935
1 Parent(s): d3bca06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -92,23 +92,23 @@ def get_conversation_chain(vectorstore):
92
  )
93
  return conversation_chain
94
 
95
- # def handle_userinput(user_question):
96
 
97
- # response = st.session_state.conversation({'question': user_question})
98
- # # response = st.session_state.conversation({'summarization': user_question})
99
- # st.session_state.chat_history = response['chat_history']
100
 
101
 
102
- # # st.empty()
103
 
104
- # for i, message in enumerate(st.session_state.chat_history):
105
- # if i % 2 == 0:
106
- # st.write(user_template.replace(
107
- # "{{MSG}}", message.content), unsafe_allow_html=True)
108
 
109
- # else:
110
- # st.write(bot_template.replace(
111
- # "{{MSG}}", message.content), unsafe_allow_html=True)
112
 
113
 
114
 
@@ -129,8 +129,8 @@ def main():
129
  st.header("Mike's PDF Chat :books:")
130
 
131
  user_question = st.text_input("Ask a question about your documents:")
132
- # if user_question:
133
- # handle_userinput(user_question)
134
 
135
  # st.write( user_template, unsafe_allow_html=True)
136
  # st.write(user_template.replace( "{{MSG}}", "Hello robot!"), unsafe_allow_html=True)
 
92
  )
93
  return conversation_chain
94
 
95
+ def handle_userinput(user_question):
96
 
97
+ response = st.session_state.conversation({'question': user_question})
98
+ # response = st.session_state.conversation({'summarization': user_question})
99
+ st.session_state.chat_history = response['chat_history']
100
 
101
 
102
+ # st.empty()
103
 
104
+ for i, message in enumerate(st.session_state.chat_history):
105
+ if i % 2 == 0:
106
+ st.write(user_template.replace(
107
+ "{{MSG}}", message.content), unsafe_allow_html=True)
108
 
109
+ else:
110
+ st.write(bot_template.replace(
111
+ "{{MSG}}", message.content), unsafe_allow_html=True)
112
 
113
 
114
 
 
129
  st.header("Mike's PDF Chat :books:")
130
 
131
  user_question = st.text_input("Ask a question about your documents:")
132
+ if user_question:
133
+ handle_userinput(user_question)
134
 
135
  # st.write( user_template, unsafe_allow_html=True)
136
  # st.write(user_template.replace( "{{MSG}}", "Hello robot!"), unsafe_allow_html=True)