@langchain/tavily
This package provides integrations for the Tavily search engine within LangChain.js. Tavily is a search engine built specifically for AI agents (LLMs), delivering real-time, accurate, and factual results at speed.
This package exposes two tools:
TavilySearch
: Performs a search optimized for LLMs and RAG.TavilyExtract
: Extracts raw content from a list of URLs.npm install @langchain/tavily
You need a Tavily API key to use these tools. You can get one here. Set it as an environment variable:
process.env.TAVILY_API_KEY = "YOUR_API_KEY";
import { TavilySearch } from "@langchain/tavily";
const tool = new TavilySearch({
maxResults: 5,
// You can set other constructor parameters here, e.g.:
// topic: "general",
// includeAnswer: false,
// includeRawContent: false,
// includeImages: false,
// searchDepth: "basic",
});
// Invoke with a query
const results = await tool.invoke({
query: "what is the current weather in SF?"
});
console.log(results);
import { TavilyExtract } from "@langchain/tavily";
const tool = new TavilyExtract({
// Constructor parameters:
// extractDepth: "basic",
// includeImages: false,
});
// Invoke with a list of URLs
const results = await tool.invoke({
urls: ["https://en.wikipedia.org/wiki/Lionel_Messi"]
});
console.log(results);
For more detailed information, check out the documentation pages:
This package is licensed under the MIT License. See the LICENSE file for details.