Update app.py
Browse files
app.py
CHANGED
|
@@ -98,19 +98,16 @@ def create_conversational_rag_chain(vectorstore):
|
|
| 98 |
rag_chain = create_retrieval_chain(ha_retriever, question_answer_chain)
|
| 99 |
msgs = StreamlitChatMessageHistory(key="special_app_key")
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
return create_rag_chain()
|
| 112 |
-
|
| 113 |
-
def main(conversational_rag_chain):
|
| 114 |
"""Main function for the Streamlit app."""
|
| 115 |
# Initialize chat history if not already present in session state
|
| 116 |
msgs = st.session_state.get("chat_history", StreamlitChatMessageHistory(key="special_app_key"))
|
|
|
|
| 98 |
rag_chain = create_retrieval_chain(ha_retriever, question_answer_chain)
|
| 99 |
msgs = StreamlitChatMessageHistory(key="special_app_key")
|
| 100 |
|
| 101 |
+
conversation_chain = RunnableWithMessageHistory(
|
| 102 |
+
rag_chain,
|
| 103 |
+
lambda session_id: msgs,
|
| 104 |
+
input_messages_key="input",
|
| 105 |
+
history_messages_key="chat_history",
|
| 106 |
+
output_messages_key="answer",
|
| 107 |
+
)
|
| 108 |
+
return conversation_chain
|
| 109 |
+
|
| 110 |
+
def main():
|
|
|
|
|
|
|
|
|
|
| 111 |
"""Main function for the Streamlit app."""
|
| 112 |
# Initialize chat history if not already present in session state
|
| 113 |
msgs = st.session_state.get("chat_history", StreamlitChatMessageHistory(key="special_app_key"))
|