ArturG9 commited on
Commit
5bd324a
1 Parent(s): 644332a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
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
- @st.cache_resource
102
- def create_rag_chain():
103
- return RunnableWithMessageHistory(
104
- rag_chain,
105
- lambda session_id: msgs,
106
- input_messages_key="input",
107
- history_messages_key="chat_history",
108
- output_messages_key="answer",
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"))