tavily

package
v0.8.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ToolName = "web_search"

Variables

View Source
var DefaultAPIKeyEnvName = "TAVILY_API_KEY"

Functions

This section is empty.

Types

type SearchOpts added in v0.6.31

type SearchOpts struct {
	// Available options: basic, advanced
	// A basic search costs 1 API Credit, while an advanced search costs 2 API Credits.
	SearchDepth string `json:"search_depth,omitempty"`
	// Available options: general, news
	Topic string `json:"topic,omitempty"`
	// Include an LLM-generated answer to the provided query.
	// `basic` or `true` returns a quick answer.
	// `advanced` returns a more detailed answer.
	IncludeAnswer bool `json:"include_answer,omitempty"`
	// Required range: 0 <= x <= 20
	MaxResults int `json:"max_results,omitempty"`
	// A list of domains to specifically include in the search results.
	IncludeDomains []string `json:"include_domains,omitempty"`
	ExcludeDomains []string `json:"exclude_domains,omitempty"`
	UseCache       bool     `json:"use_cache,omitempty"`
}

SearchOpts represents the options for a web search. See: https://docs.tavily.com/documentation/api-reference/endpoint/search

type SearchRequest

type SearchRequest struct {
	Query string `json:"Query" yaml:"Query" jsonschema:"title=Search Query,description=The query to search web."`
}

SearchRequest represents the tool input.

type SearchResult

type SearchResult struct {
	Results []tavilyModels.SearchResult `json:"results" yaml:"Results" jsonschema:"title=Search Results,description=The results from a web pages."`
	Answer  string                      `json:"answer,omitempty" yaml:"Answer" jsonschema:"title=Final Answer,description=The aggregated answer from a web search."`
}

SearchResult represents the structure for a search response

func (*SearchResult) GetContent

func (i *SearchResult) GetContent() string

func (*SearchResult) GetType

func (i *SearchResult) GetType() llms.ChatMessageType

func (*SearchResult) String

func (r *SearchResult) String() string

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool is a tool that provides a web search functionality

func New

func New() (*Tool, error)

func NewWithAPIKey

func NewWithAPIKey(apikey string) (*Tool, error)

func (*Tool) Call

func (t *Tool) Call(ctx context.Context, input string) (string, error)

func (*Tool) Description

func (t *Tool) Description() string

func (*Tool) Name

func (t *Tool) Name() string

func (*Tool) Parameters

func (t *Tool) Parameters() any

func (*Tool) RegisterMCP added in v0.1.9

func (t *Tool) RegisterMCP(registrator tools.McpServerRegistrator) error

func (*Tool) Run

func (t *Tool) Run(ctx context.Context, req *SearchRequest) (*SearchResult, error)

func (*Tool) RunMCP added in v0.1.9

func (t *Tool) RunMCP(ctx context.Context, req *SearchRequest) (*mcp.ToolResponse, error)

func (*Tool) WithBaseURL

func (t *Tool) WithBaseURL(baseURL string) *Tool

func (*Tool) WithDescription added in v0.7.35

func (t *Tool) WithDescription(description string) *Tool

func (*Tool) WithHTTPClient

func (t *Tool) WithHTTPClient(client *http.Client) *Tool

func (*Tool) WithName added in v0.7.35

func (t *Tool) WithName(name string) *Tool

func (*Tool) WithSearchOpts added in v0.6.31

func (t *Tool) WithSearchOpts(opts SearchOpts) *Tool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL