Documentation
¶
Index ¶
- Constants
- Variables
- type SearchOpts
- type SearchRequest
- type SearchResult
- type Tool
- func (t *Tool) Call(ctx context.Context, input string) (string, error)
- func (t *Tool) Description() string
- func (t *Tool) Name() string
- func (t *Tool) Parameters() *jsonschema.Schema
- func (t *Tool) RegisterMCP(registrator tools.McpServerRegistrator) error
- func (t *Tool) Run(ctx context.Context, req *SearchRequest) (*SearchResult, error)
- func (t *Tool) RunMCP(ctx context.Context, req *SearchRequest) (*mcp.ToolResponse, error)
- func (t *Tool) WithBaseURL(baseURL string) *Tool
- func (t *Tool) WithDescription(description string) *Tool
- func (t *Tool) WithHTTPClient(client *http.Client) *Tool
- func (t *Tool) WithName(name string) *Tool
- func (t *Tool) WithSearchOpts(opts SearchOpts) *Tool
Constants ¶
View Source
const ToolName = "tavily_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) 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 NewWithAPIKey ¶
func (*Tool) Description ¶
func (*Tool) Parameters ¶
func (t *Tool) Parameters() *jsonschema.Schema
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 (*Tool) WithDescription ¶ added in v0.7.35
func (*Tool) WithSearchOpts ¶ added in v0.6.31
func (t *Tool) WithSearchOpts(opts SearchOpts) *Tool
Click to show internal directories.
Click to hide internal directories.