2023-09-27 15:25:57 +00:00
|
|
|
from application.vectorstore.base import BaseVectorStore
|
|
|
|
from langchain import FAISS
|
|
|
|
from application.core.settings import settings
|
|
|
|
|
|
|
|
class FaissStore(BaseVectorStore):
|
|
|
|
|
|
|
|
def __init__(self, path, embeddings_key):
|
|
|
|
super().__init__()
|
|
|
|
self.path = path
|
|
|
|
self.docsearch = FAISS.load_local(
|
2023-09-28 23:32:19 +00:00
|
|
|
self.path, self._get_embeddings(settings.EMBEDDINGS_NAME, settings.EMBEDDINGS_KEY)
|
2023-09-27 15:25:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def search(self, *args, **kwargs):
|
|
|
|
return self.docsearch.similarity_search(*args, **kwargs)
|
2023-09-28 23:32:19 +00:00
|
|
|
|
|
|
|
def add_texts(self, *args, **kwargs):
|
|
|
|
return self.docsearch.add_texts(*args, **kwargs)
|