Tavily 리서치 통합
Tavily 리서치 통합 (Tavily research integration)
LangChain JavaScript로 Tavily 리서치 툴과 통합해요.
Tavily는 AI 에이전트(LLM)를 위해 특별히 구축된 검색 엔진으로, 실시간으로 정확하고 사실적인 결과를 빠르게 제공해요. Tavily는 LLM과 RAG에 맞춰진 종합적인 리서치 보고서를 생성하는 Research 엔드포인트를 제공해요.
개요 (Overview)
통합 세부 정보 (Integration details)
| 클래스 | 패키지 | PY 지원 | Downloads | Version |
|---|---|---|---|---|
TavilyResearch |
@langchain/tavily |
✅ |
툴 기능 (Tool features)
| 아티팩트 반환 | 네이티브 비동기 | 반환 데이터 | 가격 |
|---|---|---|---|
| ❌ | ✅ | Research report content, sources, citations | 1,000 free credits / month |
설정 (Setup)
이 통합은 @langchain/tavily 패키지에 있어요:
yarn add @langchain/tavily @langchain/core
pnpm add @langchain/tavily @langchain/core
자격 증명 (Credentials)
Tavily 대시보드에서 API 키를 만들고 TAVILY_API_KEY 환경 변수로 설정하세요.
process.env.TAVILY_API_KEY = "YOUR_API_KEY";
관측 가능성을 위해 LangSmith를 설정하는 것도 도움이 돼요 (필수는 아니에요):
process.env.LANGSMITH_TRACING = "true";
process.env.LANGSMITH_API_KEY = "your-api-key";
인스턴스화 (Instantiation)
TavilyResearch를 이렇게 import하고 인스턴스화할 수 있어요:
import { TavilyResearch } from "@langchain/tavily";
const tool = new TavilyResearch({
// model: "mini",
// citationFormat: "apa",
// stream: false,
});
model(선택): 리서치 에이전트 모델."mini","pro","auto"(기본).citationFormat(선택): 출처의 인용 포맷."numbered","mla","apa","chicago"(기본"numbered").outputSchema(선택): 리서치 출력을 형성하는 JSON Schema.stream(선택): 리서치 결과를 스트리밍할지 여부. 기본값은false.
호출 (Invocation)
인자로 직접 호출
Tavily 리서치 툴은 호출 시 다음 인자를 받아요:
input(필수): 조사할 리서치 작업 또는 질문- 선택적 오버라이드:
model,outputSchema,stream,citationFormat
await tool.invoke({
input: "What are the latest developments in AI?",
});
ToolCall로 호출
모델이 생성한 ToolCall로도 툴을 호출할 수 있는데, 이 경우 ToolMessage가 반환돼요:
// This is usually generated by a model, but we'll create a tool call directly for demo purposes.
const modelGeneratedToolCall = {
args: {
input: "What are the latest developments in AI?",
},
id: "1",
name: tool.name,
type: "tool_call",
};
await tool.invoke(modelGeneratedToolCall);
에이전트 내에서 사용 (Use within an agent)
리서치 툴을 createAgent에 전달해 에이전트가 리서치 작업으로 호출할 수 있게 하세요:
import { ChatOpenAI } from "@langchain/openai";
import { TavilyResearch } from "@langchain/tavily";
import { createAgent } from "langchain";
const llm = new ChatOpenAI({
model: "gpt-5.5",
});
const tavilyResearchTool = new TavilyResearch({
model: "mini",
});
const agent = createAgent({
model: llm,
tools: [tavilyResearchTool],
});
const userInput =
"Research the latest developments in AI agents and summarize key trends.";
const stream = await agent.streamEvents(
{ messages: [{ role: "user", content: userInput }] },
{ version: "v3" },
);
await Promise.all([
(async () => {
for await (const message of stream.messages) {
for await (const token of message.text) {
process.stdout.write(token);
}
}
})(),
(async () => {
for await (const call of stream.toolCalls) {
console.dir({ name: call.name, input: call.input }, { depth: null });
await call.output;
}
})(),
]);
await stream.output;
API reference
모든 Tavily Research API 기능과 구성에 대한 자세한 문서는 API reference를 참고하세요: docs.tavily.com/documentation/api-reference/endpoint/research
출처: 문서
본문
TavilyResearch는 LLM과 RAG에 맞춰진 종합적인 리서치 보고서를 생성하는 툴이에요. model·citationFormat·outputSchema·stream 등 옵션으로 인스턴스화하고, input 질문으로 직접 호출하거나 createAgent에 툴로 전달할 수 있어요. 반환 데이터는 리서치 보고서 내용, 출처, 인용을 포함해요.