MCPcopy Create free account
hub / github.com/Spinachead/arg / MemoFaissPool

Class MemoFaissPool

app/knowledge_base/kb_cache/faiss_cache.py:142–166  ·  view source on GitHub ↗

r""" 临时向量库的缓存池

Source from the content-addressed store, hash-verified

140
141
142class MemoFaissPool(_FaissPool):
143 r"""
144 临时向量库的缓存池
145 """
146
147 def load_vector_store(
148 self,
149 kb_name: str,
150 embed_model: str = get_default_embedding(),
151 ) -> ThreadSafeFaiss:
152 self.atomic.acquire()
153 cache = self.get(kb_name)
154 if cache is None:
155 item = ThreadSafeFaiss(kb_name, pool=self)
156 self.set(kb_name, item)
157 with item.acquire(msg="初始化"):
158 self.atomic.release()
159 # logger.info(f"loading vector store in '{kb_name}' to memory.")
160 # create an empty vector store
161 vector_store = self.new_temp_vector_store(embed_model=embed_model)
162 item.obj = vector_store
163 item.finish_loading()
164 else:
165 self.atomic.release()
166 return self.get(kb_name)
167
168
169kb_faiss_pool = KBFaissPool(cache_num=1)

Callers 1

faiss_cache.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected