From af2e0a7ede23d8be3a29748ca300c64b25b66601 Mon Sep 17 00:00:00 2001 From: Manuel <55724245+manuelescobar-dev@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:30:00 -0500 Subject: [PATCH] partners: add 'model' alias for consistency in embedding classes (#28374) **Description:** This PR introduces a `model` alias for the embedding classes that contain the attribute `model_name`, to ensure consistency across the codebase, as suggested by a moderator in a previous PR. The change aligns the usage of attribute names across the project (see for example [here](https://github.com/langchain-ai/langchain/blob/65deeddd5dfec5d51f33ebc961f09c2e47a8f064/libs/partners/groq/langchain_groq/chat_models.py#L304)). **Issue:** This PR addresses the suggestion from the review of issue #28269. **Dependencies:** None --------- Co-authored-by: Eugene Yurtsev Co-authored-by: Erick Friis --- .../langchain_huggingface/embeddings/huggingface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py b/libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py index 2bbc551f4e0..a6a70db2310 100644 --- a/libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py +++ b/libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py @@ -26,7 +26,7 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings): ) """ - model_name: str = DEFAULT_MODEL_NAME + model_name: str = Field(default=DEFAULT_MODEL_NAME, alias="model") """Model name to use.""" cache_folder: Optional[str] = None """Path to store models. @@ -68,6 +68,7 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings): model_config = ConfigDict( extra="forbid", protected_namespaces=(), + populate_by_name=True, ) def _embed(