langchain - ✅(Solved) Fix Register `perplexity_search` as a string-loadable tool name in `load_tools` [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#37086Fetched 2026-04-30 06:18:36
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1labeled ×1

Error Message

from langchain.agents import load_tools tools = load_tools(["perplexity_search"]) # raises: ValueError: Got unknown tool perplexity_search

Root Cause

I have a working implementation ready (lint + 647 tests passing locally) at PR #37083, which was auto-closed because there was no linked issue. Filing this issue per the contributor policy and would like to be assigned (@james-pplx) so the PR can be reopened. Thanks!

Fix Action

Fixed

PR fix notes

PR #37083: feat(langchain): register perplexity_search in load_tools registry

Description (problem / solution / changelog)

Closes #37089


Registers perplexity_search as a string-loadable tool name in langchain_classic.agents.load_tools, so that load_tools(["perplexity_search"]) returns a [PerplexitySearchResults()] from the langchain-perplexity partner package.

The factory lazily imports langchain_perplexity and raises a friendly ImportError ("Install langchain-perplexity: pip install -U langchain-perplexity") when the package is missing, mirroring the lazy-import / pip-install-hint pattern used for the other partner-package tools registered in langchain_community.agent_toolkits.load_tools (e.g. serpapi, metaphor-search).

The local load_tools and get_all_tool_names wrap the community implementations: perplexity_search is handled locally; every other name passes through to langchain_community unchanged.

tests/unit_tests/test_imports.py::test_no_more_changes_to_proxy_community is hash-based and intentionally bumped to reflect the redirect of load_tools / get_all_tool_names from langchain_community to the local module — this is a reduction of imports from langchain into langchain_community, which is the direction the test guards.

Verification

  • make format — clean
  • make lint — clean (ruff + mypy)
  • make test from libs/langchain/ — 647 passed, 84 skipped, 1 xfailed
  • New unit test tests/unit_tests/agents/test_load_tools.py does NOT require langchain-perplexity or any API key (uses monkeypatch on __import__ to assert the install-hint message).

Social handles (optional)

Twitter: @ LinkedIn: https://linkedin.com/in/

Changed files

  • libs/langchain/langchain_classic/agents/__init__.py (modified, +7/-4)
  • libs/langchain/langchain_classic/agents/load_tools.py (modified, +52/-1)
  • libs/langchain/tests/unit_tests/agents/test_load_tools.py (added, +52/-0)
  • libs/langchain/tests/unit_tests/test_imports.py (modified, +1/-1)

Code Example

from langchain.agents import load_tools
tools = load_tools(["perplexity_search"])  # raises: ValueError: Got unknown tool perplexity_search
RAW_BUFFERClick to expand / collapse

Checked other resources

  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-experimental package.

Feature request

langchain-perplexity ships a first-class PerplexitySearchResults tool (alongside ChatPerplexity and PerplexitySearchRetriever), but unlike other partner-package tools it can't be loaded by string name via load_tools:

from langchain.agents import load_tools
tools = load_tools(["perplexity_search"])  # raises: ValueError: Got unknown tool perplexity_search

This requires users to import the class directly, which is inconsistent with how other partner integrations are surfaced (e.g. serpapi, metaphor-search, google-search).

Motivation

Make PerplexitySearchResults discoverable through the canonical load_tools entry point so it's on equal footing with other search/retrieval tools. This is a small registration change with no new dependencies — langchain-perplexity is imported lazily and only when the user requests this tool by name.

Proposal

Register perplexity_search in libs/langchain/langchain_classic/agents/load_tools.py with a lazy importer that raises a friendly ImportError ("Install langchain-perplexity: pip install -U langchain-perplexity") if the partner package isn't installed — same pattern used for other optional partner tools.

I have a working implementation ready (lint + 647 tests passing locally) at PR #37083, which was auto-closed because there was no linked issue. Filing this issue per the contributor policy and would like to be assigned (@james-pplx) so the PR can be reopened. Thanks!

extent analysis

TL;DR

Register perplexity_search in load_tools.py with a lazy importer to make PerplexitySearchResults discoverable.

Guidance

  • Verify that PerplexitySearchResults is not already registered in load_tools.py by checking for its presence in the tool registry.
  • Add a lazy importer for perplexity_search in load_tools.py that raises a friendly ImportError if langchain-perplexity is not installed.
  • Test the registration by attempting to load perplexity_search via load_tools after implementing the change.
  • Review the working implementation at PR #37083 for reference.

Example

# Example of lazy importer for perplexity_search
from langchain.agents import ToolRegistry
from importlib import import_module

def import_perplexity_search():
    try:
        import_module("langchain_perplexity")
    except ImportError:
        raise ImportError("Install langchain-perplexity: pip install -U langchain-perplexity")

ToolRegistry.register("perplexity_search", import_perplexity_search)

Notes

This solution assumes that the langchain-perplexity package is not already installed or imported when attempting to load perplexity_search via load_tools.

Recommendation

Apply workaround by registering perplexity_search in load_tools.py as described, allowing users to load PerplexitySearchResults consistently with other partner integrations.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - ✅(Solved) Fix Register `perplexity_search` as a string-loadable tool name in `load_tools` [1 pull requests, 1 comments, 2 participants]