ash2203 commited on
Commit
b6441be
·
verified ·
1 Parent(s): bc7ddbc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -168,7 +168,11 @@ if st.session_state.query_submitted:
168
  if follow_up_query:
169
  with st.spinner("Generating response..."):
170
  try:
171
- follow_up_response = generate_detailed_explanation(follow_up_query, "") # Passing an empty context
 
 
 
 
172
  st.session_state.chat_history.append((follow_up_query, follow_up_response))
173
  st.rerun() # Rerun to display the new response
174
  except Exception as e:
 
168
  if follow_up_query:
169
  with st.spinner("Generating response..."):
170
  try:
171
+ # Get the last 5 messages from the chat history
172
+ last_5_messages = st.session_state.chat_history[-5:]
173
+ context = "\n".join([f"Q: {q}\nA: {a}" for q, a in last_5_messages])
174
+
175
+ follow_up_response = generate_detailed_explanation(follow_up_query, context)
176
  st.session_state.chat_history.append((follow_up_query, follow_up_response))
177
  st.rerun() # Rerun to display the new response
178
  except Exception as e: