From dc9e9a66db95b3c24ca0040cd529d24c2881e9ba Mon Sep 17 00:00:00 2001 From: aditya thomas Date: Fri, 29 Mar 2024 04:03:54 +0530 Subject: [PATCH] docs: update docstring of the ChatAnthropic and AnthropicLLM classes (#18649) **Description:** Update docstring of the ChatAnthropic and AnthropicLLM classes **Issue:** Not applicable **Dependencies:** None --- .../langchain_anthropic/chat_models.py | 7 +++--- .../anthropic/langchain_anthropic/llms.py | 22 +++++-------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index 0e3e668a3cb..aa39a8640cc 100644 --- a/libs/partners/anthropic/langchain_anthropic/chat_models.py +++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py @@ -134,16 +134,15 @@ def _format_messages(messages: List[BaseMessage]) -> Tuple[Optional[str], List[D class ChatAnthropic(BaseChatModel): """Anthropic chat model. - To use, you should have the packages ``anthropic`` and ``langchain-anthropic`` - installed, and the environment variable ANTHROPIC_API_KEY set with your API key, - or pass it as a named parameter to the constructor. + To use, you should have the environment variable ``ANTHROPIC_API_KEY`` + set with your API key, or pass it as a named parameter to the constructor. Example: .. code-block:: python from langchain_anthropic import ChatAnthropic - model = ChatAnthropic() + model = ChatAnthropic(model='claude-3-opus-20240229') """ class Config: diff --git a/libs/partners/anthropic/langchain_anthropic/llms.py b/libs/partners/anthropic/langchain_anthropic/llms.py index e9ab14a397a..90bcf33377d 100644 --- a/libs/partners/anthropic/langchain_anthropic/llms.py +++ b/libs/partners/anthropic/langchain_anthropic/llms.py @@ -139,29 +139,17 @@ class _AnthropicCommon(BaseLanguageModel): class AnthropicLLM(LLM, _AnthropicCommon): - """Anthropic large language models. + """Anthropic large language model. - To use, you should have the ``anthropic`` python package installed, and the - environment variable ``ANTHROPIC_API_KEY`` set with your API key, or pass - it as a named parameter to the constructor. + To use, you should have the environment variable ``ANTHROPIC_API_KEY`` + set with your API key, or pass it as a named parameter to the constructor. Example: .. code-block:: python - import anthropic - from langchain_community.llms import Anthropic + from langchain_anthropic import AnthropicLLM - model = Anthropic(model="", anthropic_api_key="my-api-key") - - # Simplest invocation, automatically wrapped with HUMAN_PROMPT - # and AI_PROMPT. - response = model("What are the biggest risks facing humanity?") - - # Or if you want to use the chat mode, build a few-shot-prompt, or - # put words in the Assistant's mouth, use HUMAN_PROMPT and AI_PROMPT: - raw_prompt = "What are the biggest risks facing humanity?" - prompt = f"{anthropic.HUMAN_PROMPT} {prompt}{anthropic.AI_PROMPT}" - response = model(prompt) + model = AnthropicLLM() """ class Config: