mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
docs: update docstring of the ChatAnthropic and AnthropicLLM classes (#18649)
**Description:** Update docstring of the ChatAnthropic and AnthropicLLM classes **Issue:** Not applicable **Dependencies:** None
This commit is contained in:
parent
f19229c564
commit
dc9e9a66db
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user