The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docstrings for `LLMs` (#7976)
Leonid Ganeline0613ed5b955b
diff --git a/langchain/llms/__init__.py b/langchain/llms/__init__.pyindex 1782a34cc7..f8c8fea525 100644--- a/langchain/llms/__init__.py+++ b/langchain/llms/__init__.py@@ -1,4 +1,4 @@-"""Wrappers on top of large language models APIs."""+"""Access to the large language model APIs and services."""from typing import Dict, Typefrom langchain.llms.ai21 import AI21diff --git a/langchain/llms/ai21.py b/langchain/llms/ai21.pyindex ae02e38fe7..5d2562a6af 100644--- a/langchain/llms/ai21.py+++ b/langchain/llms/ai21.py@@ -1,4 +1,3 @@-"""Wrapper around AI21 APIs."""from typing import Any, Dict, List, Optionalimport requests@@ -21,7 +20,7 @@ class AI21PenaltyData(BaseModel):class AI21(LLM):- """Wrapper around AI21 large language models.+ """AI21 large language models.To use, you should have the environment variable ``AI21_API_KEY``set with your API key.diff --git a/langchain/llms/aleph_alpha.py b/langchain/llms/aleph_alpha.pyindex b006ca95f5..cd4aec1682 100644--- a/langchain/llms/aleph_alpha.py+++ b/langchain/llms/aleph_alpha.py@@ -1,4 +1,3 @@-"""Wrapper around Aleph Alpha APIs."""from typing import Any, Dict, List, Optional, Sequencefrom pydantic import Extra, root_validator@@ -10,7 +9,7 @@ from langchain.utils import get_from_dict_or_envclass AlephAlpha(LLM):- """Wrapper around Aleph Alpha large language models.+ """Aleph Alpha large language models.To use, you should have the ``aleph_alpha_client`` python package installed, and theenvironment variable ``ALEPH_ALPHA_API_KEY`` set with your API key, or passdiff --git a/langchain/llms/amazon_api_gateway.py b/langchain/llms/amazon_api_gateway.pyindex 72b269dcba..1ba81c1189 100644--- a/langchain/llms/amazon_api_gateway.py+++ b/langchain/llms/amazon_api_gateway.py@@ -9,8 +9,10 @@ from langchain.llms.utils import enforce_stop_tokensclass ContentHandlerAmazonAPIGateway:- """Adapter class to prepare the inputs from Langchain to a format- that LLM model expects. Also, provides helper function to extract+ """Adapter to prepare the inputs from Langchain to a format+ that LLM model expects.++ It also provides helper function to extractthe generated text from the model response."""@classmethod@@ -25,7 +27,7 @@ class ContentHandlerAmazonAPIGateway:class AmazonAPIGateway(LLM):- """Wrapper around custom Amazon API Gateway"""+ """Amazon API Gateway to access LLM models hosted on AWS."""api_url: str"""API Gateway URL"""diff --git a/langchain/llms/anthropic.py b/langchain/llms/anthropic.pyindex 5523eec78b..a9d564fee4 100644--- a/langchain/llms/anthropic.py+++ b/langchain/llms/anthropic.py@@ -1,4 +1,3 @@-"""Wrapper around Anthropic APIs."""import reimport warningsfrom typing import Any, Callable, Dict, Generator, List, Mapping, Optional@@ -117,7 +116,7 @@ class _AnthropicCommon(BaseModel):class Anthropic(LLM, _AnthropicCommon):- r"""Wrapper around Anthropic's large language models.+ """Anthropic large language models.To use, you should have the ``anthropic`` python package installed, and theenvironment variable ``ANTHROPIC_API_KEY`` set with your API key, or passdiff --git a/langchain/llms/anyscale.py b/langchain/llms/anyscale.pyindex 307efd1e84..5a440b97d4 100644--- a/langchain/llms/anyscale.py+++ b/langchain/llms/anyscale.py@@ -1,4 +1,3 @@-"""Wrapper around Anyscale"""from typing import Any, Dict, List, Mapping, Optionalimport requests@@ -11,7 +10,8 @@ from langchain.utils import get_from_dict_or_envclass Anyscale(LLM):- """Wrapper around Anyscale Services.+ """Anyscale Service models.+To use, you should have the environment variable ``ANYSCALE_SERVICE_URL``,``ANYSCALE_SERVICE_ROUTE`` and ``ANYSCALE_SERVICE_TOKEN`` set with your AnyscaleService, or pass it as a named parameter to the constructor.diff --git a/langchain/llms/aviary.py b/langchain/llms/aviary.pyindex ba3c373072..9f9c0937d0 100644--- a/langchain/llms/aviary.py+++ b/langchain/llms/aviary.py@@ -1,4 +1,3 @@-"""Wrapper around Aviary"""import dataclassesimport osfrom typing import Any, Dict, List, Mapping, Optional, Union, cast@@ -77,14 +76,14 @@ def get_completions(class Aviary(LLM):- """Allow you to use an Aviary.+ """Aviary hosted models.Aviary is a backend for hosted models. You canfind out more about aviary athttp://github.com/ray-project/aviaryTo get a list of the models supported on an- aviary, follow the instructions on the web site to+ aviary, follow the instructions on the website toinstall the aviary CLI and then use:`aviary models`diff --git a/langchain/llms/azureml_endpoint.py b/langchain/llms/azureml_endpoint.pyindex c520d6455f..20a34613f6 100644--- a/langchain/llms/azureml_endpoint.py+++ b/langchain/llms/azureml_endpoint.py@@ -1,4 +1,3 @@-"""Wrapper around AzureML Managed Online Endpoint API."""import jsonimport urllib.requestfrom abc import abstractmethod@@ -12,7 +11,7 @@ from langchain.utils import get_from_dict_or_envclass AzureMLEndpointClient(object):- """Wrapper around AzureML Managed Online Endpoint Client."""+ """AzureML Managed Endpoint client."""def __init__(self, endpoint_url: str, endpoint_api_key: str, deployment_name: str@@ -43,8 +42,8 @@ class AzureMLEndpointClient(object):class ContentFormatterBase:- """A handler class to transform request and response of- AzureML endpoint to match with required schema.+ """Transform request and response of AzureML endpoint to match with+ required schema.""""""@@ -134,7 +133,7 @@ class DollyContentFormatter(ContentFormatterBase):class AzureMLOnlineEndpoint(LLM, BaseModel):- """Wrapper around Azure ML Hosted models using Managed Online Endpoints.+ """Azure ML Online Endpoint models.Example:.. code-block:: pythondiff --git a/langchain/llms/bananadev.py b/langchain/llms/bananadev.pyindex 32722de1aa..76dcb7b8af 100644--- a/langchain/llms/bananadev.py+++ b/langchain/llms/bananadev.py@@ -1,4 +1,3 @@-"""Wrapper around Banana API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -13,7 +12,7 @@ logger = logging.getLogger(__name__)class Banana(LLM):- """Wrapper around Banana large language models.+ """Banana large language models.To use, you should have the ``banana-dev`` python package installed,and the environment variable ``BANANA_API_KEY`` set with your API key.diff --git a/langchain/llms/base.py b/langchain/llms/base.pyindex b11712f61e..91deb9c794 100644--- a/langchain/llms/base.py+++ b/langchain/llms/base.py@@ -116,7 +116,9 @@ def update_cache(class BaseLLM(BaseLanguageModel, ABC):- """LLM wrapper should take in a prompt and return a string."""+ """Base LLM abstract interface.++ It should take in a prompt and return a string."""cache: Optional[bool] = Noneverbose: bool = Field(default_factory=_get_verbosity)@@ -560,7 +562,7 @@ class BaseLLM(BaseLanguageModel, ABC):class LLM(BaseLLM):- """LLM class that expect subclasses to implement a simpler call method.+ """Base LLM abstract class.The purpose of this class is to expose a simpler interface for workingwith LLMs, rather than expect the user to implement the full _generate method.diff --git a/langchain/llms/baseten.py b/langchain/llms/baseten.pyindex a5a314c437..d7d768d5ec 100644--- a/langchain/llms/baseten.py+++ b/langchain/llms/baseten.py@@ -1,4 +1,3 @@-"""Wrapper around Baseten deployed model API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -11,7 +10,7 @@ logger = logging.getLogger(__name__)class Baseten(LLM):- """Use your Baseten models in Langchain+ """Baseten models.To use, you should have the ``baseten`` python package installed,and run ``baseten.login()`` with your Baseten API key.@@ -60,7 +59,7 @@ class Baseten(LLM):try:import basetenexcept ImportError as exc:- raise ValueError(+ raise ImportError("Could not import Baseten Python package. ""Please install it with `pip install baseten`.") from excdiff --git a/langchain/llms/beam.py b/langchain/llms/beam.pyindex 3f6dc1bc48..47bc017dad 100644--- a/langchain/llms/beam.py+++ b/langchain/llms/beam.py@@ -1,4 +1,3 @@-"""Wrapper around Beam API."""import base64import jsonimport logging@@ -21,12 +20,12 @@ DEFAULT_SLEEP_TIME = 4class Beam(LLM):- """Wrapper around Beam API for gpt2 large language model.+ """Beam API for gpt2 large language model.To use, you should have the ``beam-sdk`` python package installed,and the environment variable ``BEAM_CLIENT_ID`` set with your client idand ``BEAM_CLIENT_SECRET`` set with your client secret. Information on how- to get these is available here: https://docs.beam.cloud/account/api-keys.+ to get this is available here: https://docs.beam.cloud/account/api-keys.The wrapper can then be called as follows, where the name, cpu, memory, gpu,python version, and python packages can be updated accordingly. Once deployed,diff --git a/langchain/llms/bedrock.py b/langchain/llms/bedrock.pyindex f923e0e5a3..481de7f568 100644--- a/langchain/llms/bedrock.py+++ b/langchain/llms/bedrock.py@@ -10,7 +10,9 @@ from langchain.llms.utils import enforce_stop_tokensclass LLMInputOutputAdapter:"""Adapter class to prepare the inputs from Langchain to a format- that LLM model expects. Also, provides helper function to extract+ that LLM model expects.++ It also provides helper function to extractthe generated text from the model response."""@classmethod@@ -47,7 +49,7 @@ class LLMInputOutputAdapter:class Bedrock(LLM):- """LLM provider to invoke Bedrock models.+ """Bedrock models.To authenticate, the AWS client uses the following methods toautomatically load credentials:diff --git a/langchain/llms/cerebriumai.py b/langchain/llms/cerebriumai.pyindex b48edd2ab2..02db1cf33e 100644--- a/langchain/llms/cerebriumai.py+++ b/langchain/llms/cerebriumai.py@@ -1,4 +1,3 @@-"""Wrapper around CerebriumAI API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -13,7 +12,7 @@ logger = logging.getLogger(__name__)class CerebriumAI(LLM):- """Wrapper around CerebriumAI large language models.+ """CerebriumAI large language models.To use, you should have the ``cerebrium`` python package installed, and theenvironment variable ``CEREBRIUMAI_API_KEY`` set with your API key.diff --git a/langchain/llms/chatglm.py b/langchain/llms/chatglm.pyindex 2ee3c01f0c..a186f3716c 100644--- a/langchain/llms/chatglm.py+++ b/langchain/llms/chatglm.py@@ -8,7 +8,7 @@ from langchain.llms.utils import enforce_stop_tokensclass ChatGLM(LLM):- """Wrapper around ChatGLM's LLM inference service.+ """ChatGLM LLM service.Example:.. code-block:: pythondiff --git a/langchain/llms/clarifai.py b/langchain/llms/clarifai.pyindex c9b059d452..2eead83592 100644--- a/langchain/llms/clarifai.py+++ b/langchain/llms/clarifai.py@@ -1,4 +1,3 @@-"""Wrapper around Clarifai's APIs."""import loggingfrom typing import Any, Dict, List, Optional@@ -13,7 +12,7 @@ logger = logging.getLogger(__name__)class Clarifai(LLM):- """Wrapper around Clarifai's large language models.+ """Clarifai large language models.To use, you should have an account on the Clarifai platform,the ``clarifai`` python package installed, and thediff --git a/langchain/llms/cohere.py b/langchain/llms/cohere.pyindex 7fd181fe3f..2e37697990 100644--- a/langchain/llms/cohere.py+++ b/langchain/llms/cohere.py@@ -1,4 +1,3 @@-"""Wrapper around Cohere APIs."""from __future__ import annotationsimport logging@@ -49,7 +48,7 @@ def completion_with_retry(llm: Cohere, **kwargs: Any) -> Any:class Cohere(LLM):- """Wrapper around Cohere large language models.+ """Cohere large language models.To use, you should have the ``cohere`` python package installed, and theenvironment variable ``COHERE_API_KEY`` set with your API key, or passdiff --git a/langchain/llms/ctransformers.py b/langchain/llms/ctransformers.pyindex 7d310109fc..86c657f618 100644--- a/langchain/llms/ctransformers.py+++ b/langchain/llms/ctransformers.py@@ -1,4 +1,3 @@-"""Wrapper around the C Transformers library."""from functools import partialfrom typing import Any, Dict, List, Optional, Sequence@@ -12,7 +11,7 @@ from langchain.llms.base import LLMclass CTransformers(LLM):- """Wrapper around the C Transformers LLM interface.+ """C Transformers LLM models.To use, you should have the ``ctransformers`` python package installed.See https://github.com/marella/ctransformersdiff --git a/langchain/llms/databricks.py b/langchain/llms/databricks.pyindex 2992a30cb6..6ed2a6fa7d 100644--- a/langchain/llms/databricks.py+++ b/langchain/llms/databricks.py@@ -130,7 +130,8 @@ def get_default_api_token() -> str:class Databricks(LLM):- """LLM wrapper around a Databricks serving endpoint or a cluster driver proxy app.+ """Databricks serving endpoint or a cluster driver proxy app for LLM.+It supports two endpoint types:* **Serving endpoint** (recommended for both production and development).diff --git a/langchain/llms/deepinfra.py b/langchain/llms/deepinfra.pyindex 0cf5768e4b..533c236284 100644--- a/langchain/llms/deepinfra.py+++ b/langchain/llms/deepinfra.py@@ -1,4 +1,3 @@-"""Wrapper around DeepInfra APIs."""from typing import Any, Dict, List, Mapping, Optionalimport requests@@ -13,7 +12,7 @@ DEFAULT_MODEL_ID = "google/flan-t5-xl"class DeepInfra(LLM):- """Wrapper around DeepInfra deployed models.+ """DeepInfra models.To use, you should have the ``requests`` python package installed, and theenvironment variable ``DEEPINFRA_API_TOKEN`` set with your API token, or passdiff --git a/langchain/llms/fake.py b/langchain/llms/fake.pyindex 3d61a951bb..4b139316a4 100644--- a/langchain/llms/fake.py+++ b/langchain/llms/fake.py@@ -1,4 +1,3 @@-"""Fake LLM wrapper for testing purposes."""from typing import Any, List, Mapping, Optionalfrom langchain.callbacks.manager import (@@ -9,7 +8,7 @@ from langchain.llms.base import LLMclass FakeListLLM(LLM):- """Fake LLM wrapper for testing purposes."""+ """Fake LLM for testing purposes."""responses: Listi: int = 0diff --git a/langchain/llms/forefrontai.py b/langchain/llms/forefrontai.pyindex 16a0ac48d4..b6c70d5c43 100644--- a/langchain/llms/forefrontai.py+++ b/langchain/llms/forefrontai.py@@ -1,4 +1,3 @@-"""Wrapper around ForefrontAI APIs."""from typing import Any, Dict, List, Mapping, Optionalimport requests@@ -11,7 +10,7 @@ from langchain.utils import get_from_dict_or_envclass ForefrontAI(LLM):- """Wrapper around ForefrontAI large language models.+ """ForefrontAI large language models.To use, you should have the environment variable ``FOREFRONTAI_API_KEY``set with your API key.diff --git a/langchain/llms/google_palm.py b/langchain/llms/google_palm.pyindex f8e1ab7a91..4b95c06369 100644--- a/langchain/llms/google_palm.py+++ b/langchain/llms/google_palm.py@@ -1,4 +1,3 @@-"""Wrapper around Google's PaLM Text APIs."""from __future__ import annotationsimport logging@@ -77,6 +76,8 @@ def _strip_erroneous_leading_spaces(text: str) -> str:class GooglePalm(BaseLLM, BaseModel):+ """Google PaLM models."""+client: Any #: :meta private:google_api_key: Optional[str]model_name: str = "models/text-bison-001"diff --git a/langchain/llms/gooseai.py b/langchain/llms/gooseai.pyindex 81f795d6ee..cde043ce22 100644--- a/langchain/llms/gooseai.py+++ b/langchain/llms/gooseai.py@@ -1,4 +1,3 @@-"""Wrapper around GooseAI API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -12,7 +11,7 @@ logger = logging.getLogger(__name__)class GooseAI(LLM):- """Wrapper around OpenAI large language models.+ """GooseAI large language models.To use, you should have the ``openai`` python package installed, and theenvironment variable ``GOOSEAI_API_KEY`` set with your API key.diff --git a/langchain/llms/gpt4all.py b/langchain/llms/gpt4all.pyindex 24a994b55a..c88374c1c0 100644--- a/langchain/llms/gpt4all.py+++ b/langchain/llms/gpt4all.py@@ -1,4 +1,3 @@-"""Wrapper for the GPT4All model."""from functools import partialfrom typing import Any, Dict, List, Mapping, Optional, Set@@ -10,7 +9,7 @@ from langchain.llms.utils import enforce_stop_tokensclass GPT4All(LLM):- r"""Wrapper around GPT4All language models.+ """GPT4All language models.To use, you should have the ``gpt4all`` python package installed, thepre-trained model file, and the model's config information.diff --git a/langchain/llms/huggingface_endpoint.py b/langchain/llms/huggingface_endpoint.pyindex 34aa98d4ab..ff38a2025a 100644--- a/langchain/llms/huggingface_endpoint.py+++ b/langchain/llms/huggingface_endpoint.py@@ -1,4 +1,3 @@-"""Wrapper around HuggingFace APIs."""from typing import Any, Dict, List, Mapping, Optionalimport requests@@ -13,7 +12,7 @@ VALID_TASKS = ("text2text-generation", "text-generation", "summarization")class HuggingFaceEndpoint(LLM):- """Wrapper around HuggingFaceHub Inference Endpoints.+ """HuggingFace Endpoint models.To use, you should have the ``huggingface_hub`` python package installed, and theenvironment variable ``HUGGINGFACEHUB_API_TOKEN`` set with your API token, or passdiff --git a/langchain/llms/huggingface_hub.py b/langchain/llms/huggingface_hub.pyindex cefa1bcc19..745f0fdccb 100644--- a/langchain/llms/huggingface_hub.py+++ b/langchain/llms/huggingface_hub.py@@ -1,4 +1,3 @@-"""Wrapper around HuggingFace APIs."""from typing import Any, Dict, List, Mapping, Optionalfrom pydantic import Extra, root_validator@@ -13,7 +12,7 @@ VALID_TASKS = ("text2text-generation", "text-generation", "summarization")class HuggingFaceHub(LLM):- """Wrapper around HuggingFaceHub models.+ """HuggingFaceHub models.To use, you should have the ``huggingface_hub`` python package installed, and theenvironment variable ``HUGGINGFACEHUB_API_TOKEN`` set with your API token, or passdiff --git a/langchain/llms/huggingface_pipeline.py b/langchain/llms/huggingface_pipeline.pyindex 92da6f5fba..ef7d428949 100644--- a/langchain/llms/huggingface_pipeline.py+++ b/langchain/llms/huggingface_pipeline.py@@ -1,4 +1,3 @@-"""Wrapper around HuggingFace Pipeline APIs."""import importlib.utilimport loggingfrom typing import Any, List, Mapping, Optional@@ -17,7 +16,7 @@ logger = logging.getLogger(__name__)class HuggingFacePipeline(LLM):- """Wrapper around HuggingFace Pipeline API.+ """HuggingFace Pipeline API.To use, you should have the ``transformers`` python package installed.diff --git a/langchain/llms/huggingface_text_gen_inference.py b/langchain/llms/huggingface_text_gen_inference.pyindex 5f33668790..1bd150de65 100644--- a/langchain/llms/huggingface_text_gen_inference.py+++ b/langchain/llms/huggingface_text_gen_inference.py@@ -1,4 +1,3 @@-"""Wrapper around Huggingface text generation inference API."""from functools import partialfrom typing import Any, Dict, List, Optional@@ -13,10 +12,9 @@ from langchain.llms.base import LLMclass HuggingFaceTextGenInference(LLM):"""- HuggingFace text generation inference API.+ HuggingFace text generation API.- This class is a wrapper around the HuggingFace text generation inference API.- It is used to generate text from a given prompt.+ It generates text from a given prompt.Attributes:- max_new_tokens: The maximum number of tokens to generate.diff --git a/langchain/llms/human.py b/langchain/llms/human.pyindex d585ee8edc..87ce68f152 100644--- a/langchain/llms/human.py+++ b/langchain/llms/human.py@@ -34,7 +34,7 @@ def _collect_user_input(class HumanInputLLM(LLM):"""- A LLM wrapper which returns user input as the response.+ It returns user input as the response."""input_func: Callable = Field(default_factory=lambda: _collect_user_input)diff --git a/langchain/llms/koboldai.py b/langchain/llms/koboldai.pyindex de7c6db2d3..ac0602794e 100644--- a/langchain/llms/koboldai.py+++ b/langchain/llms/koboldai.py@@ -1,4 +1,3 @@-"""Wrapper around KoboldAI API."""import loggingfrom typing import Any, Dict, List, Optional@@ -21,8 +20,7 @@ def clean_url(url: str) -> str:class KoboldApiLLM(LLM):- """- A class that acts as a wrapper for the Kobold API language model.+ """Kobold API language model.It includes several fields that can be used to control the text generation process.diff --git a/langchain/llms/llamacpp.py b/langchain/llms/llamacpp.pyindex a48ec6b58e..9f849e98c5 100644--- a/langchain/llms/llamacpp.py+++ b/langchain/llms/llamacpp.py@@ -1,4 +1,3 @@-"""Wrapper around llama.cpp."""import loggingfrom typing import Any, Dict, Generator, List, Optional@@ -11,7 +10,7 @@ logger = logging.getLogger(__name__)class LlamaCpp(LLM):- """Wrapper around the llama.cpp model.+ """llama.cpp model.To use, you should have the llama-cpp-python library installed, and provide thepath to the Llama model as a named parameter to the constructor.@@ -136,7 +135,7 @@ class LlamaCpp(LLM):values["client"] = Llama(model_path, **model_params)except ImportError:- raise ModuleNotFoundError(+ raise ImportError("Could not import llama-cpp-python library. ""Please install the llama-cpp-python library to ""use this embedding model: pip install llama-cpp-python"diff --git a/langchain/llms/loading.py b/langchain/llms/loading.pyindex 723606bee6..d960390818 100644--- a/langchain/llms/loading.py+++ b/langchain/llms/loading.py@@ -1,4 +1,4 @@-"""Base interface for loading large language models apis."""+"""Base interface for loading large language model APIs."""import jsonfrom pathlib import Pathfrom typing import Uniondiff --git a/langchain/llms/manifest.py b/langchain/llms/manifest.pyindex cd04c149ff..71a89ed00f 100644--- a/langchain/llms/manifest.py+++ b/langchain/llms/manifest.py@@ -1,4 +1,3 @@-"""Wrapper around HazyResearch's Manifest library."""from typing import Any, Dict, List, Mapping, Optionalfrom pydantic import Extra, root_validator@@ -8,7 +7,7 @@ from langchain.llms.base import LLMclass ManifestWrapper(LLM):- """Wrapper around HazyResearch's Manifest library."""+ """HazyResearch's Manifest library."""client: Any #: :meta private:llm_kwargs: Optional[Dict] = None@@ -27,7 +26,7 @@ class ManifestWrapper(LLM):if not isinstance(values["client"], Manifest):raise ValueErrorexcept ImportError:- raise ValueError(+ raise ImportError("Could not import manifest python package. ""Please install it with `pip install manifest-ml`.")diff --git a/langchain/llms/mlflow_ai_gateway.py b/langchain/llms/mlflow_ai_gateway.pyindex 1cf2b5221d..8ef5909678 100644--- a/langchain/llms/mlflow_ai_gateway.py+++ b/langchain/llms/mlflow_ai_gateway.py@@ -9,13 +9,18 @@ from langchain.llms.base import LLMclass Params(BaseModel, extra=Extra.allow):+ """Parameters for the MLflow AI Gateway LLM."""+temperature: float = 0.0candidate_count: int = 1+ """The number of candidates to return."""stop: Optional[List[str]] = Nonemax_tokens: Optional[int] = Noneclass MlflowAIGateway(LLM):+ """The MLflow AI Gateway models."""+route: strgateway_uri: Optional[str] = Noneparams: Optional[Params] = Nonediff --git a/langchain/llms/modal.py b/langchain/llms/modal.pyindex 3f8aba97e3..bf03947bc5 100644--- a/langchain/llms/modal.py+++ b/langchain/llms/modal.py@@ -1,4 +1,3 @@-"""Wrapper around Modal API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -13,7 +12,7 @@ logger = logging.getLogger(__name__)class Modal(LLM):- """Wrapper around Modal large language models.+ """Modal large language models.To use, you should have the ``modal-client`` python package installed.diff --git a/langchain/llms/mosaicml.py b/langchain/llms/mosaicml.pyindex de14f744ea..226b5c3b8b 100644--- a/langchain/llms/mosaicml.py+++ b/langchain/llms/mosaicml.py@@ -1,4 +1,3 @@-"""Wrapper around MosaicML APIs."""from typing import Any, Dict, List, Mapping, Optionalimport requests@@ -28,7 +27,7 @@ PROMPT_FOR_GENERATION_FORMAT = """{intro}class MosaicML(LLM):- """Wrapper around MosaicML's LLM inference service.+ """MosaicML LLM service.To use, you should have theenvironment variable ``MOSAICML_API_TOKEN`` set with your API token, or passdiff --git a/langchain/llms/nlpcloud.py b/langchain/llms/nlpcloud.pyindex aa2a62df1a..7c1b0c0acb 100644--- a/langchain/llms/nlpcloud.py+++ b/langchain/llms/nlpcloud.py@@ -1,4 +1,3 @@-"""Wrapper around NLPCloud APIs."""from typing import Any, Dict, List, Mapping, Optionalfrom pydantic import Extra, root_validator@@ -9,7 +8,7 @@ from langchain.utils import get_from_dict_or_envclass NLPCloud(LLM):- """Wrapper around NLPCloud large language models.+ """NLPCloud large language models.To use, you should have the ``nlpcloud`` python package installed, and theenvironment variable ``NLPCLOUD_API_KEY`` set with your API key.diff --git a/langchain/llms/octoai_endpoint.py b/langchain/llms/octoai_endpoint.pyindex d9e9076a0f..46c88d51ac 100644--- a/langchain/llms/octoai_endpoint.py+++ b/langchain/llms/octoai_endpoint.py@@ -1,4 +1,3 @@-"""Wrapper around OctoAI APIs."""from typing import Any, Dict, List, Mapping, Optionalfrom pydantic import Extra, root_validator@@ -10,7 +9,7 @@ from langchain.utils import get_from_dict_or_envclass OctoAIEndpoint(LLM):- """Wrapper around OctoAI Inference Endpoints.+ """OctoAI LLM Endpoints.OctoAIEndpoint is a class to interact with OctoAICompute Service large language model endpoints.diff --git a/langchain/llms/openai.py b/langchain/llms/openai.pyindex dcdb2738a7..d86bab2141 100644--- a/langchain/llms/openai.py+++ b/langchain/llms/openai.py@@ -1,4 +1,3 @@-"""Wrapper around OpenAI APIs."""from __future__ import annotationsimport logging@@ -105,7 +104,7 @@ async def acompletion_with_retry(class BaseOpenAI(BaseLLM):- """Wrapper around OpenAI large language models."""+ """Base OpenAI large language model class."""@propertydef lc_secrets(self) -> Dict[str, str]:@@ -579,7 +578,7 @@ class BaseOpenAI(BaseLLM):class OpenAI(BaseOpenAI):- """Wrapper around OpenAI large language models.+ """OpenAI large language models.To use, you should have the ``openai`` python package installed, and theenvironment variable ``OPENAI_API_KEY`` set with your API key.@@ -600,7 +599,7 @@ class OpenAI(BaseOpenAI):class AzureOpenAI(BaseOpenAI):- """Wrapper around Azure-specific OpenAI large language models.+ """Azure-specific OpenAI large language models.To use, you should have the ``openai`` python package installed, and theenvironment variable ``OPENAI_API_KEY`` set with your API key.@@ -655,7 +654,7 @@ class AzureOpenAI(BaseOpenAI):class OpenAIChat(BaseLLM):- """Wrapper around OpenAI Chat large language models.+ """OpenAI Chat large language models.To use, you should have the ``openai`` python package installed, and theenvironment variable ``OPENAI_API_KEY`` set with your API key.diff --git a/langchain/llms/openllm.py b/langchain/llms/openllm.pyindex 3b08ded337..62b1dde03f 100644--- a/langchain/llms/openllm.py+++ b/langchain/llms/openllm.py@@ -1,4 +1,3 @@-"""Wrapper around OpenLLM APIs."""from __future__ import annotationsimport copy@@ -46,7 +45,7 @@ logger = logging.getLogger(__name__)class OpenLLM(LLM):- """Wrapper for accessing OpenLLM, supporting both in-process model+ """OpenLLM, supporting both in-process modelinstance and remote OpenLLM servers.To use, you should have the openllm library installed:diff --git a/langchain/llms/openlm.py b/langchain/llms/openlm.pyindex 451558194d..c77badaa3a 100644--- a/langchain/llms/openlm.py+++ b/langchain/llms/openlm.py@@ -6,6 +6,8 @@ from langchain.llms.openai import BaseOpenAIclass OpenLM(BaseOpenAI):+ """OpenLM models."""+@propertydef _invocation_params(self) -> Dict[str, Any]:return {**{"model": self.model_name}, **super()._invocation_params}@@ -17,7 +19,7 @@ class OpenLM(BaseOpenAI):values["client"] = openlm.Completionexcept ImportError:- raise ValueError(+ raise ImportError("Could not import openlm python package. ""Please install it with `pip install openlm`.")diff --git a/langchain/llms/petals.py b/langchain/llms/petals.pyindex 84620b9e78..413437dc08 100644--- a/langchain/llms/petals.py+++ b/langchain/llms/petals.py@@ -1,4 +1,3 @@-"""Wrapper around Petals API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -13,7 +12,7 @@ logger = logging.getLogger(__name__)class Petals(LLM):- """Wrapper around Petals Bloom models.+ """Petals Bloom models.To use, you should have the ``petals`` python package installed, and theenvironment variable ``HUGGINGFACE_API_KEY`` set with your API key.diff --git a/langchain/llms/pipelineai.py b/langchain/llms/pipelineai.pyindex 67321c0ee5..b145cc4947 100644--- a/langchain/llms/pipelineai.py+++ b/langchain/llms/pipelineai.py@@ -1,4 +1,3 @@-"""Wrapper around Pipeline Cloud API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -13,7 +12,7 @@ logger = logging.getLogger(__name__)class PipelineAI(LLM, BaseModel):- """Wrapper around PipelineAI large language models.+ """PipelineAI large language models.To use, you should have the ``pipeline-ai`` python package installed,and the environment variable ``PIPELINE_API_KEY`` set with your API key.diff --git a/langchain/llms/predictionguard.py b/langchain/llms/predictionguard.pyindex b024a30fda..f91541508f 100644--- a/langchain/llms/predictionguard.py+++ b/langchain/llms/predictionguard.py@@ -1,4 +1,3 @@-"""Wrapper around Prediction Guard APIs."""import loggingfrom typing import Any, Dict, List, Optional@@ -13,7 +12,8 @@ logger = logging.getLogger(__name__)class PredictionGuard(LLM):- """Wrapper around Prediction Guard large language models.+ """Prediction Guard large language models.+To use, you should have the ``predictionguard`` python package installed, and theenvironment variable ``PREDICTIONGUARD_TOKEN`` set with your access token, or passit as a named parameter to the constructor. To use Prediction Guard's API alongdiff --git a/langchain/llms/promptlayer_openai.py b/langchain/llms/promptlayer_openai.pyindex 93176f2382..4e1089cc06 100644--- a/langchain/llms/promptlayer_openai.py+++ b/langchain/llms/promptlayer_openai.py@@ -1,4 +1,3 @@-"""PromptLayer wrapper."""import datetimefrom typing import Any, List, Optional@@ -11,7 +10,7 @@ from langchain.schema import LLMResultclass PromptLayerOpenAI(OpenAI):- """Wrapper around OpenAI large language models.+ """PromptLayer OpenAI large language models.To use, you should have the ``openai`` and ``promptlayer`` pythonpackage installed, and the environment variable ``OPENAI_API_KEY``diff --git a/langchain/llms/replicate.py b/langchain/llms/replicate.pyindex d542022f22..9cc975ae92 100644--- a/langchain/llms/replicate.py+++ b/langchain/llms/replicate.py@@ -1,4 +1,3 @@-"""Wrapper around Replicate API."""import loggingfrom typing import Any, Dict, List, Mapping, Optional@@ -12,7 +11,7 @@ logger = logging.getLogger(__name__)class Replicate(LLM):- """Wrapper around Replicate models.+ """Replicate models.To use, you should have the ``replicate`` python package installed,and the environment variable ``REPLICATE_API_TOKEN`` set with your API token.diff --git a/langchain/llms/rwkv.py b/langchain/llms/rwkv.pyindex b4d38244f7..6b717d4a12 100644--- a/langchain/llms/rwkv.py+++ b/langchain/llms/rwkv.py@@ -1,4 +1,4 @@-"""Wrapper for the RWKV model.+"""RWKV models.Based on https://github.com/saharNooby/rwkv.cpp/blob/master/rwkv/chat_with_bot.pyhttps://github.com/BlinkDL/ChatRWKV/blob/main/v2/chat.py@@ -13,7 +13,7 @@ from langchain.llms.utils import enforce_stop_tokensclass RWKV(LLM, BaseModel):- r"""Wrapper around RWKV language models.+ """RWKV language models.To use, you should have the ``rwkv`` python package installed, thepre-trained model file, and the model's config information.diff --git a/langchain/llms/sagemaker_endpoint.py b/langchain/llms/sagemaker_endpoint.pyindex 91ac69d0eb..1e28435684 100644--- a/langchain/llms/sagemaker_endpoint.py+++ b/langchain/llms/sagemaker_endpoint.py@@ -1,4 +1,4 @@-"""Wrapper around Sagemaker InvokeEndpoint API."""+"""Sagemaker InvokeEndpoint API."""from abc import abstractmethodfrom typing import Any, Dict, Generic, List, Mapping, Optional, TypeVar, Union@@ -14,8 +14,9 @@ OUTPUT_TYPE = TypeVar("OUTPUT_TYPE", bound=Union[str, List[List[float]]])class ContentHandlerBase(Generic[INPUT_TYPE, OUTPUT_TYPE]):"""A handler class to transform input from LLM to a- format that SageMaker endpoint expects. Similarly,- the class also handles transforming output from the+ format that SageMaker endpoint expects.++ Similarly, the class handles transforming output from theSageMaker endpoint to a format that LLM class expects."""@@ -62,7 +63,7 @@ class LLMContentHandler(ContentHandlerBase[str, str]):class SagemakerEndpoint(LLM):- """Wrapper around custom Sagemaker Inference Endpoints.+ """Sagemaker Inference Endpoint models.To use, you must supply the endpoint name from your deployedSagemaker model & the region where it is deployed.diff --git a/langchain/llms/self_hosted.py b/langchain/llms/self_hosted.pyindex 0eaf8ec0a8..42d45c9c54 100644--- a/langchain/llms/self_hosted.py+++ b/langchain/llms/self_hosted.py@@ -1,4 +1,3 @@-"""Run model inference on self-hosted remote hardware."""import importlib.utilimport loggingimport pickle@@ -63,7 +62,7 @@ def _send_pipeline_to_device(pipeline: Any, device: int) -> Any:class SelfHostedPipeline(LLM):- """Run model inference on self-hosted remote hardware.+ """Model inference on self-hosted remote hardware.Supported hardware includes auto-launched instances on AWS, GCP, Azure,and Lambda, as well as servers specifieddiff --git a/langchain/llms/self_hosted_hugging_face.py b/langchain/llms/self_hosted_hugging_face.pyindex e88d3fb935..2e55aaf1d2 100644--- a/langchain/llms/self_hosted_hugging_face.py+++ b/langchain/llms/self_hosted_hugging_face.py@@ -1,4 +1,3 @@-"""Wrapper around HuggingFace Pipeline API to run on self-hosted remote hardware."""import importlib.utilimport loggingfrom typing import Any, Callable, List, Mapping, Optional@@ -112,7 +111,7 @@ def _load_transformer(class SelfHostedHuggingFaceLLM(SelfHostedPipeline):- """Wrapper around HuggingFace Pipeline API to run on self-hosted remote hardware.+ """HuggingFace Pipeline API to run on self-hosted remote hardware.Supported hardware includes auto-launched instances on AWS, GCP, Azure,and Lambda, as well as servers specifieddiff --git a/langchain/llms/stochasticai.py b/langchain/llms/stochasticai.pyindex 3d1060b05e..391d9e8c40 100644--- a/langchain/llms/stochasticai.py+++ b/langchain/llms/stochasticai.py@@ -1,4 +1,3 @@-"""Wrapper around StochasticAI APIs."""import loggingimport timefrom typing import Any, Dict, List, Mapping, Optional@@ -15,7 +14,7 @@ logger = logging.getLogger(__name__)class StochasticAI(LLM):- """Wrapper around StochasticAI large language models.+ """StochasticAI large language models.To use, you should have the environment variable ``STOCHASTICAI_API_KEY``set with your API key.diff --git a/langchain/llms/textgen.py b/langchain/llms/textgen.pyindex 7d428f0e28..4e4880b82a 100644--- a/langchain/llms/textgen.py+++ b/langchain/llms/textgen.py@@ -1,4 +1,3 @@-"""Wrapper around text-generation-webui."""import loggingfrom typing import Any, Dict, List, Optional@@ -12,7 +11,7 @@ logger = logging.getLogger(__name__)class TextGen(LLM):- """Wrapper around the text-generation-webui model.+ """text-generation-webui models.To use, you should have the text-generation-webui installed, a model loaded,and --api added as a command-line option.diff --git a/langchain/llms/tongyi.py b/langchain/llms/tongyi.pyindex 39d407d274..7753213aea 100644--- a/langchain/llms/tongyi.py+++ b/langchain/llms/tongyi.py@@ -1,4 +1,3 @@-"""Wrapper around Cohere APIs."""from __future__ import annotationsimport logging@@ -89,7 +88,7 @@ def stream_generate_with_retry(llm: Tongyi, **kwargs: Any) -> Any:class Tongyi(LLM):- """Wrapper around Tongyi Qwen large language models.+ """Tongyi Qwen large language models.To use, you should have the ``dashscope`` python package installed, and theenvironment variable ``DASHSCOPE_API_KEY`` set with your API key, or passdiff --git a/langchain/llms/utils.py b/langchain/llms/utils.pyindex a42fd130ee..32fdb52eb3 100644--- a/langchain/llms/utils.py+++ b/langchain/llms/utils.py@@ -1,4 +1,4 @@-"""Common utility functions for working with LLM APIs."""+"""Common utility functions for LLM APIs."""import refrom typing import Listdiff --git a/langchain/llms/vertexai.py b/langchain/llms/vertexai.pyindex 312b3ae44b..da85f79edb 100644--- a/langchain/llms/vertexai.py+++ b/langchain/llms/vertexai.py@@ -1,4 +1,3 @@-"""Wrapper around Google VertexAI models."""from __future__ import annotationsimport asyncio@@ -142,7 +141,7 @@ class _VertexAICommon(BaseModel):class VertexAI(_VertexAICommon, LLM):- """Wrapper around Google Vertex AI large language models."""+ """Google Vertex AI large language models."""model_name: str = "text-bison""The name of the Vertex AI large language model."diff --git a/langchain/llms/writer.py b/langchain/llms/writer.pyindex 1767d8b432..546d09b04c 100644--- a/langchain/llms/writer.py+++ b/langchain/llms/writer.py@@ -1,4 +1,3 @@-"""Wrapper around Writer APIs."""from typing import Any, Dict, List, Mapping, Optionalimport requests@@ -11,7 +10,7 @@ from langchain.utils import get_from_dict_or_envclass Writer(LLM):- """Wrapper around Writer large language models.+ """Writer large language models.To use, you should have the environment variable ``WRITER_API_KEY`` and``WRITER_ORG_ID`` set with your API key and organization ID respectively.