From 7810ea58129bf72f39c6a6070c1cb177c057ae0b Mon Sep 17 00:00:00 2001 From: Leonid Ganeline Date: Mon, 14 Aug 2023 16:15:56 -0700 Subject: [PATCH] docstrings: `chat_models` consistency (#9227) Updated docstrings into the consistent format. --- libs/langchain/langchain/chat_models/anthropic.py | 2 +- libs/langchain/langchain/chat_models/anyscale.py | 2 +- libs/langchain/langchain/chat_models/azure_openai.py | 2 +- libs/langchain/langchain/chat_models/azureml_endpoint.py | 4 ++-- libs/langchain/langchain/chat_models/base.py | 2 +- libs/langchain/langchain/chat_models/google_palm.py | 4 ++-- libs/langchain/langchain/chat_models/jinachat.py | 3 +-- libs/langchain/langchain/chat_models/litellm.py | 8 +++++--- libs/langchain/langchain/chat_models/mlflow_ai_gateway.py | 5 ++--- libs/langchain/langchain/chat_models/openai.py | 2 +- .../langchain/langchain/chat_models/promptlayer_openai.py | 2 +- libs/langchain/langchain/chat_models/vertexai.py | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libs/langchain/langchain/chat_models/anthropic.py b/libs/langchain/langchain/chat_models/anthropic.py index 5090e9a0ab..e201e382f9 100644 --- a/libs/langchain/langchain/chat_models/anthropic.py +++ b/libs/langchain/langchain/chat_models/anthropic.py @@ -22,7 +22,7 @@ from langchain.schema.output import ChatGenerationChunk class ChatAnthropic(BaseChatModel, _AnthropicCommon): - """Anthropic's large language chat model. + """`Anthropic` chat large language models. To use, you should have the ``anthropic`` python package installed, and the environment variable ``ANTHROPIC_API_KEY`` set with your API key, or pass diff --git a/libs/langchain/langchain/chat_models/anyscale.py b/libs/langchain/langchain/chat_models/anyscale.py index 4426766f74..7858d2356b 100644 --- a/libs/langchain/langchain/chat_models/anyscale.py +++ b/libs/langchain/langchain/chat_models/anyscale.py @@ -28,7 +28,7 @@ DEFAULT_MODEL = "meta-llama/Llama-2-7b-chat-hf" class ChatAnyscale(ChatOpenAI): - """Wrapper around Anyscale Chat large language models. + """`Anyscale` Chat large language models. To use, you should have the ``openai`` python package installed, and the environment variable ``ANYSCALE_API_KEY`` set with your API key. diff --git a/libs/langchain/langchain/chat_models/azure_openai.py b/libs/langchain/langchain/chat_models/azure_openai.py index 7d70acc99e..5537ddb112 100644 --- a/libs/langchain/langchain/chat_models/azure_openai.py +++ b/libs/langchain/langchain/chat_models/azure_openai.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) class AzureChatOpenAI(ChatOpenAI): - """Wrapper around Azure OpenAI Chat Completion API. + """`Azure OpenAI` Chat Completion API. To use this class you must have a deployed model on Azure OpenAI. Use `deployment_name` in the diff --git a/libs/langchain/langchain/chat_models/azureml_endpoint.py b/libs/langchain/langchain/chat_models/azureml_endpoint.py index bd01d39ac2..7ceb692a68 100644 --- a/libs/langchain/langchain/chat_models/azureml_endpoint.py +++ b/libs/langchain/langchain/chat_models/azureml_endpoint.py @@ -17,7 +17,7 @@ from langchain.utils import get_from_dict_or_env class LlamaContentFormatter(ContentFormatterBase): - """Content formatter for LLaMa""" + """Content formatter for `LLaMA`.""" SUPPORTED_ROLES = ["user", "assistant", "system"] @@ -66,7 +66,7 @@ class LlamaContentFormatter(ContentFormatterBase): class AzureMLChatOnlineEndpoint(SimpleChatModel): - """Azure ML Chat Online Endpoint models. + """`AzureML` Chat models API. Example: .. code-block:: python diff --git a/libs/langchain/langchain/chat_models/base.py b/libs/langchain/langchain/chat_models/base.py index ec2d8d3426..77fb3d1df4 100644 --- a/libs/langchain/langchain/chat_models/base.py +++ b/libs/langchain/langchain/chat_models/base.py @@ -51,7 +51,7 @@ def _get_verbosity() -> bool: class BaseChatModel(BaseLanguageModel[BaseMessageChunk], ABC): - """Base class for chat models.""" + """Base class for Chat models.""" cache: Optional[bool] = None """Whether to cache the response.""" diff --git a/libs/langchain/langchain/chat_models/google_palm.py b/libs/langchain/langchain/chat_models/google_palm.py index da450ea488..47dbe4869e 100644 --- a/libs/langchain/langchain/chat_models/google_palm.py +++ b/libs/langchain/langchain/chat_models/google_palm.py @@ -38,7 +38,7 @@ logger = logging.getLogger(__name__) class ChatGooglePalmError(Exception): - """Error raised when there is an issue with the Google PaLM API.""" + """Error with the `Google PaLM` API.""" def _truncate_at_stop_tokens( @@ -214,7 +214,7 @@ async def achat_with_retry(llm: ChatGooglePalm, **kwargs: Any) -> Any: class ChatGooglePalm(BaseChatModel, BaseModel): - """Wrapper around Google's PaLM Chat API. + """`Google PaLM` Chat models API. To use you must have the google.generativeai Python package installed and either: diff --git a/libs/langchain/langchain/chat_models/jinachat.py b/libs/langchain/langchain/chat_models/jinachat.py index 700ceb3a38..4c8c621e2a 100644 --- a/libs/langchain/langchain/chat_models/jinachat.py +++ b/libs/langchain/langchain/chat_models/jinachat.py @@ -140,8 +140,7 @@ def _convert_message_to_dict(message: BaseMessage) -> dict: class JinaChat(BaseChatModel): - """Wrapper for Jina AI's LLM service, providing cost-effective - image chat capabilities. + """`Jina AI` Chat models API. To use, you should have the ``openai`` python package installed, and the environment variable ``JINACHAT_API_KEY`` set to your API key, which you diff --git a/libs/langchain/langchain/chat_models/litellm.py b/libs/langchain/langchain/chat_models/litellm.py index 5dcaa8653f..54c91f857c 100644 --- a/libs/langchain/langchain/chat_models/litellm.py +++ b/libs/langchain/langchain/chat_models/litellm.py @@ -46,7 +46,7 @@ logger = logging.getLogger(__name__) class ChatLiteLLMException(Exception): - """Error raised when there is an issue with the LiteLLM I/O Library""" + """Error with the `LiteLLM I/O` library""" def _truncate_at_stop_tokens( @@ -65,7 +65,7 @@ def _truncate_at_stop_tokens( class FunctionMessage(BaseMessage): - """A Message for passing the result of executing a function back to a model.""" + """Message for passing the result of executing a function back to a model.""" name: str """The name of the function that was executed.""" @@ -77,6 +77,8 @@ class FunctionMessage(BaseMessage): class FunctionMessageChunk(FunctionMessage, BaseMessageChunk): + """Message Chunk for passing the result of executing a function back to a model.""" + pass @@ -187,7 +189,7 @@ def _convert_message_to_dict(message: BaseMessage) -> dict: class ChatLiteLLM(BaseChatModel): - """Wrapper around the LiteLLM Model I/O library. + """`LiteLLM` Chat models API. To use you must have the google.generativeai Python package installed and either: diff --git a/libs/langchain/langchain/chat_models/mlflow_ai_gateway.py b/libs/langchain/langchain/chat_models/mlflow_ai_gateway.py index 42d4fa0d96..7645d6cac7 100644 --- a/libs/langchain/langchain/chat_models/mlflow_ai_gateway.py +++ b/libs/langchain/langchain/chat_models/mlflow_ai_gateway.py @@ -29,7 +29,7 @@ logger = logging.getLogger(__name__) # Ignoring type because below is valid pydantic code # Unexpected keyword argument "extra" for "__init_subclass__" of "object" [call-arg] class ChatParams(BaseModel, extra=Extra.allow): # type: ignore[call-arg] - """Parameters for the MLflow AI Gateway LLM.""" + """Parameters for the `MLflow AI Gateway` LLM.""" temperature: float = 0.0 candidate_count: int = 1 @@ -39,8 +39,7 @@ class ChatParams(BaseModel, extra=Extra.allow): # type: ignore[call-arg] class ChatMLflowAIGateway(BaseChatModel): - """ - Wrapper around chat LLMs in the MLflow AI Gateway. + """`MLflow AI Gateway` chat models API. To use, you should have the ``mlflow[gateway]`` python package installed. For more information, see https://mlflow.org/docs/latest/gateway/index.html. diff --git a/libs/langchain/langchain/chat_models/openai.py b/libs/langchain/langchain/chat_models/openai.py index 9b4f306db0..3ec3a2a492 100644 --- a/libs/langchain/langchain/chat_models/openai.py +++ b/libs/langchain/langchain/chat_models/openai.py @@ -118,7 +118,7 @@ def _convert_delta_to_message_chunk( class ChatOpenAI(BaseChatModel): - """Wrapper around OpenAI Chat large language models. + """`OpenAI` Chat large language models API. To use, you should have the ``openai`` python package installed, and the environment variable ``OPENAI_API_KEY`` set with your API key. diff --git a/libs/langchain/langchain/chat_models/promptlayer_openai.py b/libs/langchain/langchain/chat_models/promptlayer_openai.py index 092fdaee52..2f29b548e3 100644 --- a/libs/langchain/langchain/chat_models/promptlayer_openai.py +++ b/libs/langchain/langchain/chat_models/promptlayer_openai.py @@ -12,7 +12,7 @@ from langchain.schema.messages import BaseMessage class PromptLayerChatOpenAI(ChatOpenAI): - """Wrapper around OpenAI Chat large language models and PromptLayer. + """`PromptLayer` and `OpenAI` Chat large language models API. To use, you should have the ``openai`` and ``promptlayer`` python package installed, and the environment variable ``OPENAI_API_KEY`` diff --git a/libs/langchain/langchain/chat_models/vertexai.py b/libs/langchain/langchain/chat_models/vertexai.py index d8e5e1fd7a..e67cb77d5e 100644 --- a/libs/langchain/langchain/chat_models/vertexai.py +++ b/libs/langchain/langchain/chat_models/vertexai.py @@ -93,7 +93,7 @@ def _parse_examples(examples: List[BaseMessage]) -> List["InputOutputTextPair"]: class ChatVertexAI(_VertexAICommon, BaseChatModel): - """Wrapper around Vertex AI large language models.""" + """`Vertex AI` Chat large language models API.""" model_name: str = "chat-bison"