Browse Source

Update embedding_manager: create dir for cache

StrayWarrior 5 months ago
parent
commit
e04846e0ac
1 changed files with 3 additions and 1 deletions
  1. 3 1
      applications/embedding_manager.py

+ 3 - 1
applications/embedding_manager.py

@@ -6,7 +6,7 @@ import numpy as np
 
 
 class EmbeddingManager:
-    def __init__(self, model, emb_size = 1024, cache_file="embedding_cache", save_interval=600):
+    def __init__(self, model, emb_size=1024, cache_file="cache/embedding_cache", save_interval=600):
         self.model = model
         self.emb_size = emb_size
         self.cache_file = cache_file
@@ -67,6 +67,8 @@ class EmbeddingManager:
 
     def save_now(self):
         """Manually trigger a save to disk."""
+        if os.path.dirname(self.cache_file):
+            os.makedirs(os.path.dirname(self.cache_file), 0o755, True)
         tmp_cache_file = self.cache_file + ".tmp"
         tmp_cache_key_file = self.cache_key_file + ".tmp"
         with self.lock:  # Ensure thread-safe access