Moonfanz commited on
Commit
b8078da
·
verified ·
1 Parent(s): 1c40c0e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -268,10 +268,12 @@ def chat():
268
  preset_id = data['preset']
269
  session_id = data['session_id']
270
  chat_history = load_chat_history(session_id)
 
 
 
271
  system_instruction = ""
272
  preset_name = None
273
 
274
-
275
  for preset in PREDEFINED_PRESETS:
276
  if preset['id'] == preset_id:
277
  system_instruction = preset['content']
 
268
  preset_id = data['preset']
269
  session_id = data['session_id']
270
  chat_history = load_chat_history(session_id)
271
+ # 去除10条之前的历史记录
272
+ if len(chat_history) > 10:
273
+ chat_history = chat_history[-10:]
274
  system_instruction = ""
275
  preset_name = None
276
 
 
277
  for preset in PREDEFINED_PRESETS:
278
  if preset['id'] == preset_id:
279
  system_instruction = preset['content']