ExaRetriever 통합
ExaRetriever 통합
LangChain JavaScript로 ExaRetriever 검색기와 통합하는 방법을 알아봅니다.
Exa는 입력 질의가 주어지면 웹에서 관련 콘텐츠를 검색하는 검색 엔진이에요. ExaRetriever 검색을 시작하는 데 도움을 주는 가이드입니다. 모든 ExaRetriever 기능과 구성에 대한 자세한 문서는 API reference를 참조하세요.
출처: 문서
본문
개요
통합 세부 정보
| 검색기(Retriever) | 소스(Source) | 패키지(Package) |
|---|---|---|
| ExaRetriever | 웹의 정보(Information on the web). | @langchain/exa |
설정
API 키를 환경 변수로 설정해야 합니다.
Exa 클래스는 API 키를 찾을 때 기본적으로 EXASEARCH_API_KEY를 사용합니다.
export EXASEARCH_API_KEY="your-api-key"
개별 질의에서 자동 추적을 받으려면 아래 주석을 해제해 LangSmith API 키를 설정할 수도 있습니다:
// process.env.LANGSMITH_API_KEY = "<YOUR API KEY HERE>";
// process.env.LANGSMITH_TRACING = "true";
설치
이 검색기는 @langchain/exa 패키지에 있습니다:
npm install @langchain/exa @langchain/core
yarn add @langchain/exa @langchain/core
pnpm add @langchain/exa @langchain/core
인스턴스화(Instantiation)
이제 검색기를 인스턴스화할 수 있습니다:
import { ExaRetriever } from "@langchain/exa";
import Exa from "exa-js";
const retriever = new ExaRetriever({
// @lc-ts-ignore
client: new Exa(
process.env.EXASEARCH_API_KEY // default API key
),
searchArgs: {
numResults: 2,
}
});
사용법(Usage)
const query = "What did the speaker say about Justice Breyer in the 2022 State of the Union?";
await retriever.invoke(query);
[
Document {
pageContent: 'President Biden’s State of the Union Address\n' +
'Madam Speaker, ... (전문 transcript)',
metadata: {
score: 0.16303963959217072,
title: '2022 State of the Union Address | The White House',
id: 'https://www.whitehouse.gov/state-of-the-union-2022/',
url: 'https://www.whitehouse.gov/state-of-the-union-2022/',
publishedDate: '2022-02-25',
author: ''
},
id: undefined
},
Document {
pageContent: "The President. Thank you all very, very much. ... (전문 transcript)",
metadata: {
score: 0.16301880776882172,
title: 'Address Before a Joint Session of the Congress on the State of the Union',
id: 'https://www.presidency.ucsb.edu/documents/address-before-joint-session-the-congress-the-state-the-union-28',
url: 'https://www.presidency.ucsb.edu/documents/address-before-joint-session-the-congress-the-state-the-union-28',
publishedDate: '2022-03-01',
author: ''
},
id: undefined
}
]
API reference
모든 ExaRetriever 기능과 구성에 대한 자세한 문서는 API reference를 참조하세요.
더 알아보기 (Learn more)
- 이 문서를 MCP로 연결하면 Claude, VSCode 등에서 실시간 답변을 받을 수 있어요.
- GitHub에서 이 페이지 편집하기 또는 이슈 제출하기.