.ipynb
.pdf
Anthropic
 Contents 
ChatAnthropic also supports async and streaming functionality:
Anthropic#
Anthropic is an American artificial intelligence (AI) startup and
public-benefit corporation, founded by former members of OpenAI. Anthropic specializes in developing general AI
systems and language models, with a company ethos of responsible AI usage.
Anthropic develops a chatbot, named Claude. Similar to ChatGPT, Claude uses a messaging
interface where users can submit questions or requests and receive highly detailed and relevant responses.
from langchain.chat_models import ChatAnthropic
from langchain.prompts.chat import (
    ChatPromptTemplate,
    SystemMessagePromptTemplate,
    AIMessagePromptTemplate,
    HumanMessagePromptTemplate,
)
from langchain.schema import (
    AIMessage,
    HumanMessage,
    SystemMessage
)
chat = ChatAnthropic()
messages = [
    HumanMessage(content="Translate this sentence from English to French. I love programming.")
]
chat(messages)
AIMessage(content=" J'aime programmer. ", additional_kwargs={})
ChatAnthropic also supports async and streaming functionality:#
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
await chat.agenerate([messages])
LLMResult(generations=[[ChatGeneration(text=" J'aime la programmation.", generation_info=None, message=AIMessage(content=" J'aime la programmation.", additional_kwargs={}))]], llm_output={})
chat = ChatAnthropic(streaming=True, verbose=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]))
chat(messages)
 J'adore programmer.
AIMessage(content=" J'adore programmer.", additional_kwargs={})
previous
Integrations
next
Azure
 Contents
  
ChatAnthropic also supports async and streaming functionality:
rtdocs_stable/api.python.langchain.com/en/stable/modules/models/chat/integrations/anthropic.html