Jina me donne toujours RuntimeError: The size of tensor a (5) must match the size of tensor b (4) at non-singleton dimension 1
23 lines
791 B
Python
23 lines
791 B
Python
from langchain_huggingface import HuggingFaceEmbeddings
|
||
from langchain_chroma import Chroma # TODO plus tard, ramplacer par PG Vector
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
base_dir:str = Path(sys.argv[0]).resolve().parent.as_posix() # Récupérer le chemin vers le point d'entrée du programme
|
||
bdd_path:str = base_dir + "/../chroma_db/"
|
||
|
||
EMBEDDINGS = HuggingFaceEmbeddings(model_name="intfloat/multilingual-e5-large", model_kwargs={"trust_remote_code": True})
|
||
CHROMA = Chroma(
|
||
persist_directory=bdd_path,
|
||
embedding_function=EMBEDDINGS
|
||
)
|
||
|
||
class VectorDatabase: # Classe pour récupérer la BDD
|
||
|
||
@staticmethod
|
||
def getChroma()->Chroma:
|
||
return CHROMA
|
||
|
||
@staticmethod
|
||
def getEmbeddings()->'Embeddings Hugging Face':
|
||
return EMBEDDINGS |