YingxuHe commited on
Commit
3ae4433
·
1 Parent(s): f539d23

enable session based memory

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -47,12 +47,14 @@ def add_text(history, text):
47
 
48
 
49
  def bot(history):
50
- print(history)
 
 
 
51
  history[-1][1] = ""
52
  user_message = history[-1][0]
53
 
54
  for chunk in chain.stream({"text": user_message}):
55
- print(chunk)
56
  history[-1][1] += chunk["text"]
57
  yield history
58
 
 
47
 
48
 
49
  def bot(history):
50
+ # session based memory
51
+ if len(history) == 1:
52
+ chain.memory.clear()
53
+
54
  history[-1][1] = ""
55
  user_message = history[-1][0]
56
 
57
  for chunk in chain.stream({"text": user_message}):
 
58
  history[-1][1] += chunk["text"]
59
  yield history
60