Update app.py
Browse files
app.py
CHANGED
@@ -91,10 +91,12 @@ def handle_userinput(user_question,vectorstore):
|
|
91 |
config={
|
92 |
"configurable": {"session_id": "k"}
|
93 |
},
|
94 |
-
)["answer"]
|
|
|
|
|
95 |
st.session_state.chat_history = response['chat_history']
|
96 |
|
97 |
-
for i, message in enumerate(
|
98 |
if i % 2 == 0:
|
99 |
st.write(user_template.replace(
|
100 |
"{{MSG}}", message.content), unsafe_allow_html=True)
|
@@ -150,6 +152,16 @@ def create_conversational_rag_chain(vectorstore):
|
|
150 |
rag_chain = create_retrieval_chain(ha_retriever, question_answer_chain)
|
151 |
msgs = StreamlitChatMessageHistory(key="special_app_key")
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
return rag_chain
|
154 |
|
155 |
|
|
|
91 |
config={
|
92 |
"configurable": {"session_id": "k"}
|
93 |
},
|
94 |
+
)["answer"]
|
95 |
+
|
96 |
+
|
97 |
st.session_state.chat_history = response['chat_history']
|
98 |
|
99 |
+
for i, message in enumerate(msgs):
|
100 |
if i % 2 == 0:
|
101 |
st.write(user_template.replace(
|
102 |
"{{MSG}}", message.content), unsafe_allow_html=True)
|
|
|
152 |
rag_chain = create_retrieval_chain(ha_retriever, question_answer_chain)
|
153 |
msgs = StreamlitChatMessageHistory(key="special_app_key")
|
154 |
|
155 |
+
conversational_rag_chain = RunnableWithMessageHistory(
|
156 |
+
rag_chain,
|
157 |
+
lambda session_id: msgs,
|
158 |
+
input_messages_key="input",
|
159 |
+
history_messages_key="chat_history",
|
160 |
+
output_messages_key="answer",
|
161 |
+
return_source_documents = True
|
162 |
+
)
|
163 |
+
|
164 |
+
|
165 |
return rag_chain
|
166 |
|
167 |
|