ArturG9 commited on
Commit
fe8eb6d
1 Parent(s): 2f6f04b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -86,22 +86,16 @@ def main(vectorstore):
86
  def handle_userinput(user_question,vectorstore):
87
  Rag_chain = create_conversational_rag_chain(vectorstore)
88
  msgs = StreamlitChatMessageHistory(key="special_app_key")
89
- response = Rag_chain.invoke(
90
- {"input": user_question},
91
-
92
- config={
93
- "configurable": {"session_id": "k"}
94
- },
95
- )["answer"]
96
-
97
  st.session_state.chat_history = response['chat_history']
98
 
99
- # Display messages in chat history
100
  for i, message in enumerate(st.session_state.chat_history):
101
  if i % 2 == 0:
102
- st.write(user_template.replace("{{MSG}}", message.content), unsafe_allow_html=True)
 
103
  else:
104
- st.write(bot_template.replace("{{MSG}}", message.content), unsafe_allow_html=True)
 
105
 
106
  if 'retrieved_documents' in response:
107
  st.subheader("Retrieved Documents")
@@ -167,7 +161,7 @@ def create_conversational_rag_chain(vectorstore):
167
  return_source_documents=True
168
  )
169
 
170
- return conversational_rag_chain
171
 
172
 
173
 
 
86
  def handle_userinput(user_question,vectorstore):
87
  Rag_chain = create_conversational_rag_chain(vectorstore)
88
  msgs = StreamlitChatMessageHistory(key="special_app_key")
89
+ response = st.session_state.conversation({'question': user_question})
 
 
 
 
 
 
 
90
  st.session_state.chat_history = response['chat_history']
91
 
 
92
  for i, message in enumerate(st.session_state.chat_history):
93
  if i % 2 == 0:
94
+ st.write(user_template.replace(
95
+ "{{MSG}}", message.content), unsafe_allow_html=True)
96
  else:
97
+ st.write(bot_template.replace(
98
+ "{{MSG}}", message.content), unsafe_allow_html=True)
99
 
100
  if 'retrieved_documents' in response:
101
  st.subheader("Retrieved Documents")
 
161
  return_source_documents=True
162
  )
163
 
164
+ return rag_chain
165
 
166
 
167