Skip to content

Conversation

@wucm667
Copy link

@wucm667 wucm667 commented Jan 26, 2026

Description

This PR adds a new Tavily search tool component that implements the InvokableTool interface 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 implementation
  • components/tool/tavily/tavily_test.go - Unit tests (12 test cases, 100% coverage)
  • components/tool/tavily/go.mod - Go module definition
  • components/tool/tavily/README.md - English documentation
  • components/tool/tavily/README_zh.md - Chinese documentation
  • components/tool/tavily/examples/main.go - Usage example

Features

  • ✅ Support for basic and advanced search depths
  • ✅ Configurable search topics (general/news)
  • ✅ AI-generated answer inclusion
  • ✅ Raw content retrieval option
  • ✅ Domain filtering (include/exclude)
  • ✅ Custom API endpoint support
  • ✅ HTTP proxy support
  • ✅ Automatic retry with exponential backoff
  • ✅ Full compatibility with Eino's tool system

Implementation Details

  • Follows the same design patterns as existing search tools (Bing, DuckDuckGo, Google)
  • Adheres to Effective Go and Go Code Review Comments
  • Comprehensive error handling and context cancellation support
  • Well-documented with both English and Chinese README files

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

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
Copilot AI review requested due to automatic review settings January 26, 2026 03:20
@CLAassistant
Copy link

CLAassistant commented Jan 26, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants