Feat/modernize langchain integration crawl tools#31
Draft
daveomri wants to merge 78 commits intofeat/modernize-langchain-integrationfrom
Draft
Feat/modernize langchain integration crawl tools#31daveomri wants to merge 78 commits intofeat/modernize-langchain-integrationfrom
daveomri wants to merge 78 commits intofeat/modernize-langchain-integrationfrom
Conversation
…mline client handling and error management
…media tools for apify integration
…ms and message for empty dataset
…y tools to enforce safety constraints
…and maintability; update test cases for better formatting and error handling
…eat/modernize-langchain-integration-native-components
…eat/modernize-langchain-integration-native-components
…ser_search, google_maps_search, youtube_scrape, ecommerce_scrape)
…raperTool, ApifyEcommerceScraperTool
…andle_tool_error)
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
Third PR on top of
feat/modernize-langchain-integration; builds on the [native components PR](https://github.com/apify/langchain-apify/tree/feat/modernize-langchain-integration-native-components) and adds the Search & Crawling Actor tools layer: four newBaseToolsubclasses wrapping search, maps, video, and e-commerce Actors. Upcoming PR will fold this together with social-media tools and documentation onto [feat/modernize-langchain-integration](https://github.com/apify/langchain-apify/tree/feat/modernize-langchain-integration) before merging tomain.New code: ~426 lines — Tests: ~337 lines
ApifyRAGWebBrowserTool([_actor_tools.py](langchain_apify/_actor_tools.py))apify/rag-web-browser. Returns JSON withrunmetadata (run_id / status / dataset_id / timestamps) anditems(crawled-page dicts). Distinct fromApifySearchRetriever(which returns LangChainDocumentobjects); this tool returns JSON for agent tool-calling.ApifyGoogleMapsTool([_actor_tools.py](langchain_apify/_actor_tools.py))compass/crawler-google-places. Requiredquery, optionalmax_results(default 10) andlanguage(ISO code). Returns JSON withrunmetadata anditems(place dicts).ApifyYouTubeScraperTool([_actor_tools.py](langchain_apify/_actor_tools.py))streamers/youtube-scraper. Requiredsearch_query, optionalsearch_type: Literal['search', 'video', 'channel'](defaultsearch),max_results(default 10). TightLiteralat the LLM boundary, loosestr+ runtimeValueErrorat the_client.pyboundary so direct callers get the same protection.ApifyEcommerceScraperTool([_actor_tools.py](langchain_apify/_actor_tools.py))apify/e-commerce-scraping-tool. Requiredurl, optionalmax_results(default 20). Bare-URL design intentionally keeps the LLM-facing surface minimal; selector hints can be added later if real users hit empty-result issues.APIFY_SEARCH_TOOLSconvenience listlist[type[BaseTool]]exported alongsideAPIFY_CORE_TOOLSandAPIFY_ACTOR_TOOLSfor selective agent binding:[ApifyRAGWebBrowserTool, ApifyGoogleMapsTool, ApifyYouTubeScraperTool, ApifyEcommerceScraperTool].ApifyToolsClientadditions ([_client.py](langchain_apify/_client.py))google_maps_search,youtube_scrape,ecommerce_scrape) and one rename + signature change:rag_web_search→rag_web_browser_search, now returning(run, items)like the other helpers so the tool layer can build_run_meta(run). All four reuse the existingrun_actor_and_get_itemsplumbing — transport-error wrapping and_check_run_statuscome for free.ApifySearchRetriever([retrievers.py](langchain_apify/retrievers.py))_, items = self._client.rag_web_browser_search(...)); behaviour andDocumentshape are unchanged.ApifyActorsTool/ApifyDatasetLoader/ApifyWrapperuntouched. Therag_web_searchrename is internal — only the retriever consumed it, and that's updated in-tree.run_inputkeys),youtube_scrapeenum validation, happy-path JSON shape per tool, parametrized_TOOL_INVOCATIONSbattery coveringRuntimeError → ToolException, empty-dataset,handle_tool_error=Trueswallow, missing-token, plus inheritance / metadata /APIFY_SEARCH_TOOLSmembership. Existingtest_retrievers.pytests rewired for the new tuple-return helper.Review strategy
Suggested reading order:
ApifyToolsClientmethods plus therag_web_search → rag_web_browser_searchrename — each follows the same pattern as the native-components methods._ApifyGenericToolsubclasses and their input schemas (homogeneous; once one clicks the rest read fast).APIFY_SEARCH_TOOLSlist and__all__additions.Merge strategy
This PR targets
feat/modernize-langchain-integration, notmain. It depends on the [native components PR](https://github.com/apify/langchain-apify/tree/feat/modernize-langchain-integration-native-components) being merged first —_actor_tools.pyextends the file introduced there and consumes_run_meta/_ApifyGenericToolfromtools.py. Once native components is merged into the integration branch, this PR will be rebased and opened for review. Social-media tools and docs will follow as separate PRs on the same integration branch before the final merge tomain.