MCPcopy Create free account
hub / github.com/DVampire/FinAgent / load_local

Method load_local

finagent/memory/faiss.py:167–193  ·  view source on GitHub ↗

Load FAISS index and index_to_key from disk. Args: embedding_provider: Embeddings to use when generating queries memory_path: folder path to load index and index_to_key from. name: name of the vectorstore. Returns: The FAISS vectorsto

(
        self,
        embedding_dim: int,
        memory_path: str,
    )

Source from the content-addressed store, hash-verified

165 return key_and_score
166
167 def load_local(
168 self,
169 embedding_dim: int,
170 memory_path: str,
171 ):
172 """Load FAISS index and index_to_key from disk.
173
174 Args:
175 embedding_provider: Embeddings to use when generating queries
176 memory_path: folder path to load index and index_to_key from.
177 name: name of the vectorstore.
178
179 Returns:
180 The FAISS vectorstore class.
181 """
182 # load index separately since it is not picklable
183 faiss = dependable_faiss_import()
184 index = faiss.read_index(os.path.join(memory_path, "index.faiss"))
185
186 # load index_to_key
187 with open(os.path.join(memory_path, "index2key.pkl"), "rb") as f:
188 index_to_key = pickle.load(f)
189
190 self.index = index
191 self.index_to_key = index_to_key
192 self.memory_path = memory_path
193 self.embedding_dim = embedding_dim
194
195 def save_local(self, memory_path = None) -> None:
196

Callers 7

load_localMethod · 0.95
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 1

dependable_faiss_importFunction · 0.85

Tested by

no test coverage detected