Source code for langchain_community.llms.mlflow
from __future__ import annotations
from typing import Any, Dict, List, Mapping, Optional
from urllib.parse import urlparse
from langchain_core.callbacks import CallbackManagerForLLMRun
from langchain_core.language_models import LLM
from langchain_core.pydantic_v1 import BaseModel, Extra, Field, PrivateAttr
# Ignoring type because below is valid pydantic code
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
[docs]class Params(BaseModel, extra=Extra.allow):  # type: ignore[call-arg]
    """Parameters for MLflow"""
    temperature: float = 0.0
    n: int = 1
    stop: Optional[List[str]] = None
    max_tokens: Optional[int] = None
[docs]class Mlflow(LLM):
    """Wrapper around completions LLMs in MLflow.
    To use, you should have the `mlflow[genai]` python package installed.
    For more information, see https://mlflow.org/docs/latest/llms/deployments/server.html.
    Example:
        .. code-block:: python
            from langchain_community.llms import Mlflow
            completions = Mlflow(
                target_uri="http://localhost:5000",
                endpoint="test",
                params={"temperature": 0.1}
            )
    """
    endpoint: str
    """The endpoint to use."""
    target_uri: str
    """The target URI to use."""
    temperature: float = 0.0
    """The sampling temperature."""
    n: int = 1
    """The number of completion choices to generate."""
    stop: Optional[List[str]] = None
    """The stop sequence."""