Spaces:
Runtime error
Runtime error
Update memory.py
Browse files
memory.py
CHANGED
@@ -1,19 +1,15 @@
|
|
1 |
-
|
2 |
-
import numpy as np
|
3 |
-
import faiss
|
4 |
-
|
5 |
-
model = SentenceTransformer("all-MiniLM-L6-v2")
|
6 |
|
7 |
def init_memory():
|
8 |
-
|
9 |
-
return {"
|
10 |
|
11 |
def add_to_memory(text, memory):
|
12 |
-
|
13 |
-
memory["index"].add(np.array([vec]))
|
14 |
memory["texts"].append(text)
|
|
|
|
|
15 |
|
16 |
-
def search_memory(query, memory
|
17 |
-
|
18 |
-
|
19 |
-
return [memory["texts"][i] for i in I[0] if i < len(memory["texts"])]
|
|
|
1 |
+
# memory.py
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def init_memory():
|
4 |
+
# Initialize memory as a simple dict with a 'texts' list
|
5 |
+
return {"texts": []}
|
6 |
|
7 |
def add_to_memory(text, memory):
|
8 |
+
# Append text to memory, keep last 100 entries
|
|
|
9 |
memory["texts"].append(text)
|
10 |
+
if len(memory["texts"]) > 100:
|
11 |
+
memory["texts"] = memory["texts"][-100:]
|
12 |
|
13 |
+
def search_memory(query, memory):
|
14 |
+
# Placeholder: Return last few memory entries related to query (simple all for now)
|
15 |
+
return memory["texts"][-5:]
|
|