Anthropic 통합
Anthropic 통합
LangChain JavaScript로 Anthropic과 통합하는 방법을 알아봅니다.
Anthropic 모델과 관련된 모든 기능을 다룹니다.
Anthropic은 AI 안전 및 연구 회사이며 Claude의 창시자예요. 이 페이지는 Anthropic 모델과 LangChain 사이의 모든 통합을 다룹니다.
출처: 문서
본문
프롬프팅 모범 사례(Prompting best practices)
Anthropic 모델은 OpenAI 모델과 비교해 몇 가지 프롬프팅 모범 사례가 있습니다.
시스템 메시지는 첫 번째 메시지만 가능합니다.
Anthropic 모델은 시스템 메시지가 프롬프트의 첫 번째여야 합니다.
ChatAnthropic
ChatAnthropic은 LangChain의 ChatModel의 하위 클래스이며, ChatPromptTemplate과 함께 사용할 때 가장 잘 작동합니다. 다음 코드로 이 래퍼를 import할 수 있습니다:
LangChain 패키지 설치에 대한 일반적인 지침은 이 섹션을 참조하세요.
npm install @langchain/anthropic @langchain/core
import { ChatAnthropic } from "@langchain/anthropic";
const model = new ChatAnthropic({});
ChatModel로 작업할 때는 프롬프트를 ChatPromptTemplate으로 설계하는 것이 좋습니다. 아래는 그 예시입니다:
import { ChatPromptTemplate } from "@langchain/classic/prompts";
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a helpful chatbot"],
["human", "Tell me a joke about {topic}"],
]);
그런 다음 다음과 같이 체인에서 사용할 수 있습니다:
const chain = prompt.pipe(model);
await chain.invoke({ topic: "bears" });
멀티모달 입력을 포함한 더 많은 예시는 채팅 모델 통합 페이지를 참조하세요.
더 알아보기 (Learn more)
- 이 문서를 MCP로 연결하면 Claude, VSCode 등에서 실시간 답변을 받을 수 있어요.
- GitHub에서 이 페이지 편집하기 또는 이슈 제출하기.