-
Notifications
You must be signed in to change notification settings - Fork 250
feat(tool/tavily): add Tavily search tool implementation #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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