Perplexity 통합
Perplexity 통합
LangChain JavaScript로 Perplexity와 통합하는 방법을 알아봅니다.
Perplexity는 무제한 Pro Search, 업그레이드된 AI 모델, 무제한 파일 업로드, 이미지 생성, API 크레딧으로 인터넷을 검색하는 가장 강력한 방법입니다.
출처: 문서
본문
설치 및 설정(Installation and setup)
LangChain JavaScript용 Perplexity 통합 패키지를 설치하세요:
npm install @langchain/perplexity @langchain/core
yarn add @langchain/perplexity @langchain/core
pnpm add @langchain/perplexity @langchain/core
Perplexity API 키 대시보드에서 API 키를 받아 PERPLEXITY_API_KEY 환경 변수로 설정하세요. 자세한 내용은 Perplexity 시작 가이드를 참조하세요.
export PERPLEXITY_API_KEY="your-api-key"
채팅 모델(Chat model)
사용 예시를 참조하세요.
import { ChatPerplexity } from "@langchain/perplexity";
ChatPerplexity는 useResponsesApi: true를 전달하거나(tools: [{ type: "web_search" }]를 전달하면 자동으로 활성화됩니다) Perplexity Agent API를 대상으로 할 수도 있습니다. 자세한 내용과 예시는 채팅 페이지의 Agent API 지원을 참조하세요.
검색기(Retriever)
PerplexitySearchRetriever를 사용해 Perplexity Search API에서 웹 검색 결과를 표준 검색 파이프라인의 Document 객체로 가져올 수 있습니다.
사용 예시를 참조하세요.
import { PerplexitySearchRetriever } from "@langchain/perplexity";
도구(Tools)
Perplexity를 에이전트 도구로 사용해 에이전트에 Perplexity Search API 접근 권한을 부여할 수 있습니다.
사용 예시를 참조하세요.
PerplexitySearchResults
Perplexity Search API를 질의하고 결과(제목, URL, 스니펫, 날짜, 마지막 업데이트)의 JSON 배열을 반환하는 도구입니다.
import { PerplexitySearchResults } from "@langchain/perplexity";
컴포넌트 참조(Components reference)
| 클래스(Class) | 추상화(Abstraction) | Import 경로 | 설명(Description) |
|---|---|---|---|
ChatPerplexity |
채팅 모델(Chat model) | import { ChatPerplexity } from "@langchain/perplexity" |
접지된(grounded) 채팅 완성을 위해 Perplexity API를 래핑하는 채팅 모델. |
PerplexitySearchRetriever |
검색기(Retriever) | import { PerplexitySearchRetriever } from "@langchain/perplexity" |
Perplexity Search API에서 Document 객체를 반환하는 검색기. |
PerplexitySearchResults |
도구(Tool) | import { PerplexitySearchResults } from "@langchain/perplexity" |
에이전트를 위해 Perplexity Search API 결과를 JSON 배열로 반환하는 도구. |
더 알아보기 (Learn more)
- 이 문서를 MCP로 연결하면 Claude, VSCode 등에서 실시간 답변을 받을 수 있어요.
- GitHub에서 이 페이지 편집하기 또는 이슈 제출하기.