feat(tool/tavily): add Tavily search tool implementation#667
Open
wucm667 wants to merge 7 commits intocloudwego:mainfrom
Open
feat(tool/tavily): add Tavily search tool implementation#667wucm667 wants to merge 7 commits intocloudwego:mainfrom
wucm667 wants to merge 7 commits intocloudwego:mainfrom
Conversation
This commit adds a new Tavily search tool component that implements the InvokableTool interface for the Eino framework. Features: - Support for basic and advanced search depths - Configurable search topics (general/news) - AI-generated answer inclusion - Raw content retrieval - Domain filtering (include/exclude) - Custom API endpoint support - HTTP proxy support - Automatic retry with exponential backoff - Comprehensive test coverage (12 test cases) The implementation follows the same patterns as existing search tools (Bing, DuckDuckGo, Google) and includes: - Main implementation (tavily.go) - Unit tests (tavily_test.go) - Example usage (examples/main.go) - English and Chinese documentation
There was a problem hiding this comment.
Pull request overview
This PR adds a new Tavily search tool component that integrates the Tavily search API with the Eino framework, providing AI-powered web search capabilities through the InvokableTool interface.
Changes:
- Implements a comprehensive Tavily search tool with configurable search parameters including depth, topic, domain filtering, and AI-generated answers
- Includes robust error handling with retry logic, context cancellation support, and HTTP proxy configuration
- Provides complete test coverage with 12 test cases covering validation, search functionality, retry logic, and error scenarios
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
components/tool/tavily/tavily.go |
Main implementation with configuration validation, HTTP client setup, and search functionality |
components/tool/tavily/tavily_test.go |
Comprehensive unit tests with mock server implementations |
components/tool/tavily/go.mod |
Module definition with dependencies |
components/tool/tavily/go.sum |
Dependency checksums |
components/tool/tavily/examples/main.go |
Usage example demonstrating basic search with AI answers |
components/tool/tavily/README.md |
English documentation with configuration guide and examples |
components/tool/tavily/README_zh.md |
Chinese documentation matching English version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new Tavily search tool component that implements the
InvokableToolinterface for the Eino framework, providing web search capabilities powered by Tavily API.Motivation
Tavily is a powerful search API optimized for LLM applications, offering AI-generated answers and comprehensive search results. Adding Tavily as a search tool option enriches the Eino ecosystem and provides users with more choices for web search integration.
Changes
New Files
components/tool/tavily/tavily.go- Main implementationcomponents/tool/tavily/tavily_test.go- Unit tests (12 test cases, 100% coverage)components/tool/tavily/go.mod- Go module definitioncomponents/tool/tavily/README.md- English documentationcomponents/tool/tavily/README_zh.md- Chinese documentationcomponents/tool/tavily/examples/main.go- Usage exampleFeatures
Implementation Details
Testing
All tests passed successfully:
$ go test -v ./... === RUN TestConfig_validate --- PASS: TestConfig_validate (0.00s) === RUN TestConfig_validate_defaults --- PASS: TestConfig_validate_defaults (0.00s) === RUN TestNewTool --- PASS: TestNewTool (0.00s) === RUN TestTavilySearch_Search --- PASS: TestTavilySearch_Search (0.00s) === RUN TestTavilySearch_Search_EmptyQuery --- PASS: TestTavilySearch_Search_EmptyQuery (0.00s) === RUN TestTavilySearch_Search_APIError --- PASS: TestTavilySearch_Search_APIError (0.00s) === RUN TestTavilySearch_Search_WithRetry --- PASS: TestTavilySearch_Search_WithRetry (0.30s) === RUN TestTavilySearch_Search_ContextCancelled --- PASS: TestTavilySearch_Search_ContextCancelled (5.00s) === RUN TestNewTavilySearch_WithProxy --- PASS: TestNewTavilySearch_WithProxy (0.00s) === RUN TestNewTavilySearch_InvalidProxy --- PASS: TestNewTavilySearch_InvalidProxy (0.00s) === RUN TestSearchDepthConstants --- PASS: TestSearchDepthConstants (0.00s) === RUN TestTopicConstants --- PASS: TestTopicConstants (0.00s) PASS ok github.com/cloudwego/eino-ext/components/tool/tavily 5.780s