mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-08 20:41:52 +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):
|
class ChatAnthropic(BaseChatModel):
|
||||||
"""Anthropic chat model.
|
"""Anthropic chat model.
|
||||||
|
|
||||||
To use, you should have the packages ``anthropic`` and ``langchain-anthropic``
|
To use, you should have the environment variable ``ANTHROPIC_API_KEY``
|
||||||
installed, and the environment variable ANTHROPIC_API_KEY set with your API key,
|
set with your API key, or pass it as a named parameter to the constructor.
|
||||||
or pass it as a named parameter to the constructor.
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain_anthropic import ChatAnthropic
|
from langchain_anthropic import ChatAnthropic
|
||||||
|
|
||||||
model = ChatAnthropic()
|
model = ChatAnthropic(model='claude-3-opus-20240229')
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
@ -139,29 +139,17 @@ class _AnthropicCommon(BaseLanguageModel):
|
|||||||
|
|
||||||
|
|
||||||
class AnthropicLLM(LLM, _AnthropicCommon):
|
class AnthropicLLM(LLM, _AnthropicCommon):
|
||||||
"""Anthropic large language models.
|
"""Anthropic large language model.
|
||||||
|
|
||||||
To use, you should have the ``anthropic`` python package installed, and the
|
To use, you should have the environment variable ``ANTHROPIC_API_KEY``
|
||||||
environment variable ``ANTHROPIC_API_KEY`` set with your API key, or pass
|
set with your API key, or pass it as a named parameter to the constructor.
|
||||||
it as a named parameter to the constructor.
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import anthropic
|
from langchain_anthropic import AnthropicLLM
|
||||||
from langchain_community.llms import Anthropic
|
|
||||||
|
|
||||||
model = Anthropic(model="<model_name>", anthropic_api_key="my-api-key")
|
model = AnthropicLLM()
|
||||||
|
|
||||||
# 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)
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
Loading…
Reference in New Issue
Block a user