@kaibanjs/tools
Version:
A set of tools to work with LLMs and KaibanJS
107 lines (106 loc) • 3.29 kB
TypeScript
/**
* Tavily Search Results
*
* This tool integrates with Tavily (https://tavily.com/), an advanced search engine
* optimized for comprehensive, accurate, and trusted results. It's particularly
* useful for retrieving current information and answering questions about recent events.
*
* Tavily provides AI-optimized search capabilities that deliver high-quality,
* relevant results, making it ideal for AI applications and Large Language
* Models (LLMs).
*
* Key features of Tavily:
* - Delivers accurate and trusted search results
* - Optimized for current events and real-time information
* - Returns well-structured JSON data ready for LLM consumption
* - Includes content relevance scoring and filtering
*
* For more information about Tavily, visit: https://tavily.com/
*/
import { StructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
/**
* Type for the parameters in TavilySearchResults
* @typedef {string} TavilySearchParams
* @example
* {
* searchQuery: "search query"
*/
type TavilySearchParams = {
searchQuery: string;
};
/**
* Configuration options for the TavilySearchResults tool
* @interface TavilySearchFields
* @property {string} apiKey - The API key for the Tavily search engine
* @property {number} [maxResults] - The maximum number of results to return
*/
interface TavilySearchFields {
apiKey: string;
maxResults?: number;
}
/**
* Type for the results from the Tavily search engine
* @typedef {Object} TavilyResult
* @property {string} title - The title of the result
* @property {string} url - The URL of the result
* @property {string} content - The content of the result
* @property {number} score - The score of the result
* @property {Object} [key: string]: any - Additional properties of the result
*/
type TavilyResult = {
title: string;
url: string;
content: string;
score: number;
[key: string]: any;
};
/**
* Type for the error response from the Tavily search engine
* @typedef {string} TavilyError
* @example
* "Invalid API key"
*/
type TavilyError = string;
/**
* Type for the response from the Tavily search engine
* @typedef {TavilyResult[] | TavilyError} TavilyResponse
* @example
* [
* {
* title: "Tavily Search Results",
* url: "https://tavily.com",
* content: "Tavily is a search engine that provides AI-optimized search capabilities.",
* score: 0.95
* }
* ]
*/
type TavilyResponse = TavilyResult[] | TavilyError;
/**
* TavilySearchResults tool class
* @extends StructuredTool
*/
export declare class TavilySearchResults extends StructuredTool {
private apiKey;
private maxResults;
private httpClient;
name: string;
description: string;
schema: z.ZodObject<{
searchQuery: z.ZodString;
}, "strip", z.ZodTypeAny, {
searchQuery: string;
}, {
searchQuery: string;
}>;
/**
* @param {TavilySearchFields} fields - The fields for the Tavily search engine
*/
constructor(fields: TavilySearchFields);
/**
* @param {TavilySearchParams} input - The input for the Tavily search engine
* @returns {Promise<TavilyResponse>} The response from the Tavily search engine
*/
_call(input: TavilySearchParams): Promise<TavilyResponse>;
}
export {};