Skip to content

The agent engineering platform.

docs: update docstring of the ChatAnthropic and AnthropicLLM classes (#18649)

aditya thomasdc9e9a66db95
diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py
index 0e3e668a3c..aa39a8640c 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 e9ab14a397..90bcf33377 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="<model_name>", 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: