from functools import lru_cache from langchain_huggingface import HuggingFaceEmbeddings from app.config import settings @lru_cache def get_embeddings() -> HuggingFaceEmbeddings: return HuggingFaceEmbeddings( model_name=settings.embedding_model, model_kwargs={"trust_remote_code": True}, encode_kwargs={"normalize_embeddings": True}, )