Spaces:
Sleeping
Sleeping
Neurolingua
commited on
Commit
•
aefdf99
1
Parent(s):
0e6ad12
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,18 @@ if not os.path.exists(UPLOAD_FOLDER):
|
|
29 |
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
30 |
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
conversation_memory = ConversationBufferMemory(max_size=2)
|
34 |
|
35 |
account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
|
|
|
29 |
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
30 |
|
31 |
|
32 |
+
class ConversationBufferMemory:
|
33 |
+
def __init__(self, max_size):
|
34 |
+
self.memory = []
|
35 |
+
self.max_size = max_size
|
36 |
+
|
37 |
+
def add_to_memory(self, interaction):
|
38 |
+
self.memory.append(interaction)
|
39 |
+
if len(self.memory) > self.max_size:
|
40 |
+
self.memory.pop(0)
|
41 |
+
|
42 |
+
def get_memory(self):
|
43 |
+
return self.memory
|
44 |
conversation_memory = ConversationBufferMemory(max_size=2)
|
45 |
|
46 |
account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
|