pragneshbarik commited on
Commit
6e67a0c
·
1 Parent(s): bb3e3ae

added sliding window

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -179,10 +179,7 @@ if prompt := st.chat_input("Chat with Ikigai Docs..."):
179
 
180
  st.session_state.inference_time.append(tock - tick)
181
 
182
- len_response = 0
183
 
184
- st.session_state["tokens_used"] = len_response + \
185
- st.session_state["tokens_used"]
186
 
187
  formatted_links = ", ".join(links)
188
  with st.chat_message("assistant"):
@@ -204,7 +201,12 @@ if prompt := st.chat_input("Chat with Ikigai Docs..."):
204
  placeholder.markdown(full_response + "▌")
205
  placeholder.markdown(full_response)
206
 
 
 
207
 
 
 
 
208
  st.session_state.history.append([prompt, full_response])
209
  st.session_state.history.append(identity_change)
210
 
 
179
 
180
  st.session_state.inference_time.append(tock - tick)
181
 
 
182
 
 
 
183
 
184
  formatted_links = ", ".join(links)
185
  with st.chat_message("assistant"):
 
201
  placeholder.markdown(full_response + "▌")
202
  placeholder.markdown(full_response)
203
 
204
+ len_response = (len(prompt.split()) + len(full_response.split())) * 1.25
205
+ st.session_state["tokens_used"] = len_response + st.session_state["tokens_used"]
206
 
207
+ if st.session_state["tokens_used"] > 15000 :
208
+ st.session_state.history = st.session_state.history[-3:]
209
+
210
  st.session_state.history.append([prompt, full_response])
211
  st.session_state.history.append(identity_change)
212