All functionality related to Anthropic models..Anthropic is an AI safety and research company, and is the creator of Claude.
This page covers all integrations between Anthropic models and LangChain.
Anthropic models have several prompting best practices compared to OpenAI models.System Messages may only be the first messageAnthropic models require any system messages to be the first one in your prompts.
ChatAnthropic is a subclass of LangChain’s ChatModel, meaning it works best with ChatPromptTemplate.
You can import this wrapper with the following code:
import { ChatAnthropic } from "@langchain/anthropic";const model = new ChatAnthropic({});
When working with ChatModels, it is preferred that you design your prompts as ChatPromptTemplates.
Here is an example below of doing that:
Copy
Ask AI
import { ChatPromptTemplate } from "langchain/prompts";const prompt = ChatPromptTemplate.fromMessages([ ["system", "You are a helpful chatbot"], ["human", "Tell me a joke about {topic}"],]);