Spaces:
Sleeping
Sleeping
File size: 535 Bytes
f73646a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | conversation_memory = []
def add_memory(question, answer):
conversation_memory.append({
"question": question,
"answer": answer
})
# keep last 5 q
if len(conversation_memory) > 5:
conversation_memory.pop(0)
def get_memory_text():
if not conversation_memory:
return ""
text = "\nPREVIOUS CONVERSATION:\n"
for item in conversation_memory:
text += f"Q: {item['question']}\n"
text += f"A: {item['answer']}\n\n"
return text |