Skip to content

Conversation

@divyeshradadiya
Copy link

@divyeshradadiya divyeshradadiya commented Oct 25, 2025

feat(serpex): Add Serpex web search tool integration

Description

This PR adds official Serpex web search integration to LangChain.js. Serpex provides multi-engine web search results in structured JSON format, supporting Google, Bing, DuckDuckGo, Brave, Yahoo, and Yandex search engines with intelligent auto-routing and retry logic.

Changes

  • Add Serpex tool for multi-engine web search (Google, Bing, DuckDuckGo, Brave, Yahoo, Yandex)
  • Support for auto-routing with retry logic
  • Configurable search parameters (engine, category, time_range)
  • Comprehensive test suite
  • Full documentation with examples
  • API endpoint: https://api.serpex.dev

Files Added

  • libs/langchain-community/src/tools/serpex.ts - Main Serpex tool implementation
  • libs/langchain-community/src/tools/tests/serpex.test.ts - Comprehensive test suite
  • SERPEX_INTEGRATION.md - Integration documentation with examples

Files Modified

  • libs/langchain-community/src/load/import_map.ts - Added Serpex import mapping

Features

  • 🔍 Multi-Engine Support: Automatic routing across 7 search engines (auto, google, bing, duckduckgo, brave, yahoo, yandex)
  • ⚙️ Configurable Parameters: engine, category (web), time_range (all, day, week, month, year)
  • 🛡️ Error Handling: Robust error handling with detailed error messages
  • 📦 Response Parsing: Intelligent parsing for answers, results, suggestions, corrections
  • 🔄 Agent Compatible: Works seamlessly with LangChain agents and chains

API Details

  • Endpoint: https://api.serpex.dev/api/search
  • Authentication: Bearer token in Authorization header
  • Cost: 1 credit per request (all engines)
  • Rate Limit: 300 requests/second

Testing

All tests pass successfully with real API:

  • ✅ Basic Search (auto engine) - 11 results, 1200ms
  • ✅ Google Search with Time Range - 14 results, 1400ms
  • ✅ Bing Search - 18 results, 1734ms
  • ✅ DuckDuckGo Search - 7 results, 837ms

Run tests:

npm test libs/langchain-community/src/tools/tests/serpex.test.ts

Or with real API:

SERPEX_API_KEY=your-key node test_langchain_js_integration.js

Backwards Compatibility

✅ No breaking changes. This is a new tool addition that doesn't affect existing functionality.

Dependencies

No new dependencies required. Uses existing LangChain dependencies and native fetch API.


Thanks for reviewing! This integration provides seamless multi-engine web search for LangChain.js applications.

My Twitter - @kartey_r

- Add Serpex tool for multi-engine web search (Google, Bing, DuckDuckGo, Brave, Yahoo, Yandex)
- Support for auto-routing with retry logic
- Configurable search parameters (engine, category, time_range)
- Comprehensive test suite
- Full documentation with examples
- API endpoint: https://api.serpex.dev
@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2025

⚠️ No Changeset found

Latest commit: 9742529

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant