@langchain/tavily
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@langchain/tavily

NPM - Version

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.

Installation

npm install @langchain/tavily

Setup

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";

Usage

TavilySearch

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);

TavilyExtract

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);

Documentation

For more detailed information, check out the documentation pages:

License

This package is licensed under the MIT License. See the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i @langchain/tavily

Weekly Downloads

1,364

Version

0.1.1

License

MIT

Unpacked Size

70.9 kB

Total Files

19

Last publish

Collaborators

  • hwchase17
  • jacoblee93
  • basproul
  • eric_langchain
  • andrewnguonly
  • nfcampos
  • vbarda
  • davidduong
  • maddyadams
  • sam_noyes
  • benjamincburns