Drop langchain-community (closes the last item in #510) - #543
Open
amirfz wants to merge 1 commit into
Open
Conversation
langchain-community was down to a single use: GoogleSerperAPIWrapper in tools.py, called only via its own private _google_serper_api_results method — never the documented public API. Upstream now prints its own "being sunset, no longer actively maintained" deprecation warning on import, so it won't receive future security fixes. Replaced it with a small direct call to the Serper.dev API (the wrapper's method was already just a thin requests.post), removing the dependency entirely. Removing langchain-community also dropped langchain-classic, and with it sqlalchemy/greenlet, which were only ever present transitively. sqlalchemy is a real, direct need — database/user_usage_tracker.py imports it for the usage-tracking DB — so it's now declared explicitly in the main dependency group instead of riding in on a package that's going away. This is the same "core code path depends on a package the published package doesn't install" trap flagged in issue #510's review for word2number/pypdf/en_core_web_sm; caught here by actually uninstalling langchain-community and running the real suite rather than just checking imports in sherpa_ai/. Added a focused unit test for the new _google_serper_search helper (there was no direct test of the old wrapper call either), and verified it by mutating the request headers and confirming the test catches it, then reverting. Full suite (385 passed, 2 skipped) run for real with langchain-community and langchain-classic uninstalled from the environment, not just removed from pyproject.toml. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
amirfz
force-pushed
the
deps/drop-langchain-community
branch
from
August 1, 2026 15:11
8288b8c to
2e366c6
Compare
20001LastOrder
requested changes
Aug 7, 2026
20001LastOrder
left a comment
Collaborator
There was a problem hiding this comment.
Generally looks good, but I think a wrapper class is better than a function
| HTTP_GET_TIMEOUT = 20.0 | ||
|
|
||
|
|
||
| def _google_serper_search(query: str) -> dict: |
Collaborator
There was a problem hiding this comment.
I would prefer to implement it as a property rather than a function. Something like:
class GoogleSerperAPIWrapper(BaseModel):
url: str = https://google.serper.dev/search
api_key = cfg.SERPER_API_KEY
def search(self, query):
...
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.
Summary
Closes #510 — this was the one explicitly open item left after #509 ("Still open — dropping
langchain-community, the one item genuinely left").langchain-communitywas down to a single use in the whole package:GoogleSerperAPIWrapperintools.py, called only via its own private_google_serper_api_resultsmethod. Upstream prints its own "being sunset, no longer actively maintained" deprecation warning on import (visible in every test run all session), so it won't get future security fixes.Changes
_google_serper_search()intools.py— a directrequests.posttohttps://google.serper.dev/search, replicating exactly what the wrapper's private method did (verified by reading its source). Removed thelangchain_communityimport entirely.langchain-communityfrompyproject.toml.langchain-communityalso dropped its transitive dependencylangchain-classic, which was silently carryingsqlalchemy/greenlet.sqlalchemyis a genuine direct need —database/user_usage_tracker.pyimports it for the usage-tracking DB — so it was only ever available by accident. Same class of bug the maintainer flagged in Dependency risk-surface reduction: drop dead/heavy deps (importlib, hydra-core, transformers, tokenizers, markdown), narrow unstructured, de-dupe spacy #510's review forword2number/pypdf/en_core_web_sm("core code paths depend on packages the published package doesn't install"). Now declared explicitly in the main dependency group with a comment explaining why.conftest.py'smock_env,test_citation_validation.py) that patchedlangchain_community.utilities.GoogleSerperAPIWrapper._google_serper_api_resultsto patchsherpa_ai.tools._google_serper_searchinstead._google_serper_searchitself — there was no direct test of the old wrapper call either, only indirect coverage throughSearchTool.poetry.lockregenerated with the same Poetry version as the existing lock (2.2.1) to avoid unrelated format churn.Verification
_google_serper_search's header construction and confirmed the new test fails; reverted and confirmed green.langchain-communityandlangchain-classicuninstalled from the environment, not just removed frompyproject.toml— this is what caught thesqlalchemygap; a grep-only check would have missed it sincesqlalchemyis imported directly insherpa_ai/, just never declared.import sherpa_ai.toolsprints nothing now, vs. thelangchain-community is being sunset...warning on every prior test run this session).Test plan
pytest tests/unit_tests/tools/test_search_tool.py— new + existing tests passlangchain-community/langchain-classicnot installedCo-Authored-By: Claude Sonnet 5 noreply@anthropic.com