The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
add model_revison parameter to ModelScopeEmbeddings (#8669)
sumandeng53e4148a1b37
diff --git a/libs/langchain/langchain/embeddings/modelscope_hub.py b/libs/langchain/langchain/embeddings/modelscope_hub.pyindex 6b6ebab424..541aeaa358 100644--- a/libs/langchain/langchain/embeddings/modelscope_hub.py+++ b/libs/langchain/langchain/embeddings/modelscope_hub.py@@ -1,4 +1,4 @@-from typing import Any, List+from typing import Any, List, Optionalfrom pydantic import BaseModel, Extra@@ -15,12 +15,13 @@ class ModelScopeEmbeddings(BaseModel, Embeddings):from langchain.embeddings import ModelScopeEmbeddingsmodel_id = "damo/nlp_corom_sentence-embedding_english-base"- embed = ModelScopeEmbeddings(model_id=model_id)+ embed = ModelScopeEmbeddings(model_id=model_id, model_revision="v1.0.0")"""embed: Anymodel_id: str = "damo/nlp_corom_sentence-embedding_english-base""""Model name to use."""+ model_revision: Optional[str] = Nonedef __init__(self, **kwargs: Any):"""Initialize the modelscope"""@@ -28,14 +29,16 @@ class ModelScopeEmbeddings(BaseModel, Embeddings):try:from modelscope.pipelines import pipelinefrom modelscope.utils.constant import Tasks-- self.embed = pipeline(Tasks.sentence_embedding, model=self.model_id)-except ImportError as e:raise ImportError("Could not import some python packages.""Please install it with `pip install modelscope`.") from e+ self.embed = pipeline(+ Tasks.sentence_embedding,+ model=self.model_id,+ model_revision=self.model_revision,+ )class Config:"""Configuration for this pydantic object."""