# Methods to encode text import numpy as np from langchain_community.embeddings import HuggingFaceEmbeddings def encode_text(text, embedding_model='sentence-transformers/all-MiniLM-L6-v2', as_array=True): """Encodes the input text using the provided embedding model.""" embedding_model = HuggingFaceEmbeddings(model_name=embedding_model) encoded_input = embedding_model.embed_query(text) if as_array: return np.array(encoded_input) else: return encoded_input