Spaces:
Runtime error
Runtime error
Commit ·
591bf90
1
Parent(s): 87906ed
Upload 53 files
Browse files- swarm_config.yaml +1 -1
- swarmai/Swarm.py +8 -2
- swarmai/utils/memory/VectorMemory.py +2 -1
swarm_config.yaml
CHANGED
|
@@ -7,7 +7,7 @@ swarm:
|
|
| 7 |
- n: 2
|
| 8 |
type: googler
|
| 9 |
run_dir: ./tmp/swarm
|
| 10 |
-
timeout_min:
|
| 11 |
task:
|
| 12 |
global_goal: A new startup just send us their pitch. Find if the startup is worth
|
| 13 |
investing in. The startup is called Brainamics and it is in the space of brain
|
|
|
|
| 7 |
- n: 2
|
| 8 |
type: googler
|
| 9 |
run_dir: ./tmp/swarm
|
| 10 |
+
timeout_min: 5
|
| 11 |
task:
|
| 12 |
global_goal: A new startup just send us their pitch. Find if the startup is worth
|
| 13 |
investing in. The startup is called Brainamics and it is in the space of brain
|
swarmai/Swarm.py
CHANGED
|
@@ -221,9 +221,15 @@ class Swarm:
|
|
| 221 |
# delete all files and subdirectories in the data directory
|
| 222 |
for dir_i in self.data_dir.iterdir():
|
| 223 |
if dir_i.is_dir():
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
| 225 |
else:
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
| 227 |
self.log(f"Deleted old {dir_i}")
|
| 228 |
except Exception:
|
| 229 |
pass
|
|
|
|
| 221 |
# delete all files and subdirectories in the data directory
|
| 222 |
for dir_i in self.data_dir.iterdir():
|
| 223 |
if dir_i.is_dir():
|
| 224 |
+
try:
|
| 225 |
+
shutil.rmtree(dir_i, ignore_errors=True)
|
| 226 |
+
except Exception:
|
| 227 |
+
self.log(f"Coudn't delete {dir_i}")
|
| 228 |
else:
|
| 229 |
+
try:
|
| 230 |
+
dir_i.unlink()
|
| 231 |
+
except Exception:
|
| 232 |
+
self.log(f"Coudn't delete {dir_i}")
|
| 233 |
self.log(f"Deleted old {dir_i}")
|
| 234 |
except Exception:
|
| 235 |
pass
|
swarmai/utils/memory/VectorMemory.py
CHANGED
|
@@ -77,13 +77,14 @@ class VectorMemory:
|
|
| 77 |
- texts (list[str]): a list of the top k results
|
| 78 |
"""
|
| 79 |
self.count = self.db._collection.count()
|
|
|
|
| 80 |
if k > self.count:
|
| 81 |
k = self.count - 1
|
| 82 |
if k <= 0:
|
| 83 |
return None
|
| 84 |
|
| 85 |
if type == "mmr":
|
| 86 |
-
texts = self.db.max_marginal_relevance_search(query=query, k=k, fetch_k = min(
|
| 87 |
texts = [text.page_content for text in texts]
|
| 88 |
elif type == "cos":
|
| 89 |
texts = self.db.similarity_search_with_score(query=query, k=k)
|
|
|
|
| 77 |
- texts (list[str]): a list of the top k results
|
| 78 |
"""
|
| 79 |
self.count = self.db._collection.count()
|
| 80 |
+
print(f"Searching {self.count} entries")
|
| 81 |
if k > self.count:
|
| 82 |
k = self.count - 1
|
| 83 |
if k <= 0:
|
| 84 |
return None
|
| 85 |
|
| 86 |
if type == "mmr":
|
| 87 |
+
texts = self.db.max_marginal_relevance_search(query=query, k=k, fetch_k = min(10,self.count))
|
| 88 |
texts = [text.page_content for text in texts]
|
| 89 |
elif type == "cos":
|
| 90 |
texts = self.db.similarity_search_with_score(query=query, k=k)
|