nickmuchi commited on
Commit
b8e67ea
β€’
1 Parent(s): 925f238

Update pages/3_Earnings_Semantic_Search_πŸ”Ž_.py

Browse files
pages/3_Earnings_Semantic_Search_πŸ”Ž_.py CHANGED
@@ -109,11 +109,17 @@ try:
109
 
110
  docsearch = create_vectorstore(earnings_text,title, embedding_model)
111
 
 
112
 
113
  if "messages" not in st.session_state or st.sidebar.button("Clear message history"):
114
  st.session_state["messages"] = [AIMessage(content=starter_message)]
115
 
116
-
 
 
 
 
 
117
 
118
  if user_question := st.chat_input(placeholder=starter_message):
119
  st.chat_message("user").write(user_question)
@@ -121,15 +127,6 @@ try:
121
  with st.chat_message("assistant"):
122
 
123
  st_callback = StreamlitCallbackHandler(st.container())
124
-
125
- memory, agent_executor = create_memory_and_agent(user_question,docsearch)
126
-
127
- for msg in st.session_state.messages:
128
- if isinstance(msg, AIMessage):
129
- st.chat_message("assistant").write(msg.content)
130
- elif isinstance(msg, HumanMessage):
131
- st.chat_message("user").write(msg.content)
132
- memory.chat_memory.add_message(msg)
133
 
134
  response = agent_executor(
135
  {"input": user_question, "history": st.session_state.messages},
 
109
 
110
  docsearch = create_vectorstore(earnings_text,title, embedding_model)
111
 
112
+ memory, agent_executor = create_memory_and_agent(earnings_text,docsearch)
113
 
114
  if "messages" not in st.session_state or st.sidebar.button("Clear message history"):
115
  st.session_state["messages"] = [AIMessage(content=starter_message)]
116
 
117
+ for msg in st.session_state.messages:
118
+ if isinstance(msg, AIMessage):
119
+ st.chat_message("assistant").write(msg.content)
120
+ elif isinstance(msg, HumanMessage):
121
+ st.chat_message("user").write(msg.content)
122
+ memory.chat_memory.add_message(msg)
123
 
124
  if user_question := st.chat_input(placeholder=starter_message):
125
  st.chat_message("user").write(user_question)
 
127
  with st.chat_message("assistant"):
128
 
129
  st_callback = StreamlitCallbackHandler(st.container())
 
 
 
 
 
 
 
 
 
130
 
131
  response = agent_executor(
132
  {"input": user_question, "history": st.session_state.messages},