Spaces:
Sleeping
Sleeping
enable session based memory
Browse files
app.py
CHANGED
@@ -47,12 +47,14 @@ def add_text(history, text):
|
|
47 |
|
48 |
|
49 |
def bot(history):
|
50 |
-
|
|
|
|
|
|
|
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 |
|