[docs]classMlflowAIGatewayEmbeddings(Embeddings,BaseModel):"""MLflow AI Gateway embeddings. To use, you should have the ``mlflow[gateway]`` python package installed. For more information, see https://mlflow.org/docs/latest/gateway/index.html. Example: .. code-block:: python from langchain_community.embeddings import MlflowAIGatewayEmbeddings embeddings = MlflowAIGatewayEmbeddings( gateway_uri="<your-mlflow-ai-gateway-uri>", route="<your-mlflow-ai-gateway-embeddings-route>" ) """route:str"""The route to use for the MLflow AI Gateway API."""gateway_uri:Optional[str]=None"""The URI for the MLflow AI Gateway API."""def__init__(self,**kwargs:Any):warnings.warn("`MlflowAIGatewayEmbeddings` is deprecated. Use `MlflowEmbeddings` or ""`DatabricksEmbeddings` instead.",DeprecationWarning,)try:importmlflow.gatewayexceptImportErrorase:raiseImportError("Could not import `mlflow.gateway` module. ""Please install it with `pip install mlflow[gateway]`.")fromesuper().__init__(**kwargs)ifself.gateway_uri:mlflow.gateway.set_gateway_uri(self.gateway_uri)def_query(self,texts:List[str])->List[List[float]]:try:importmlflow.gatewayexceptImportErrorase:raiseImportError("Could not import `mlflow.gateway` module. ""Please install it with `pip install mlflow[gateway]`.")fromeembeddings=[]fortxtin_chunk(texts,20):resp=mlflow.gateway.query(self.route,data={"text":txt})# response is List[List[float]]ifisinstance(resp["embeddings"][0],List):embeddings.extend(resp["embeddings"])# response is List[float]else:embeddings.append(resp["embeddings"])returnembeddings