Add LangChain Search and Extract tools - #52
Open
georgeatparallel wants to merge 6 commits into
Open
Conversation
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.
This adds
@parallel-web/langchainso you can give a LangChain agent Parallel Search and Extract without writing the wrappers yourself.createSearchTool()andcreateExtractTool()go straight into your agent'stoolsarray.Your app chooses the API key and request settings. The agent gets text with source URLs, capped at 20,000 characters by default, and your app can keep the full API response in the tool artifact. The tools handle input checks and cancellation, and make sure extraction failures still show up when the text gets cut short.
There's a runnable research example too. It shows how to search for sources, read pages, and ask for an answer with citations.
The package isn't on npm yet. Adding it here doesn't publish it; the first release needs the owner setup in
PUBLISHING.md.Testing note: Ran the example against a real model and the live Parallel APIs, both from the repo and from a clean project with the packed package installed. The final run took 8.4 seconds: the agent searched, read the relevant page, and returned an answer citing the sources it actually retrieved. The raw tool artifacts matched the API responses.
Also tried one valid URL and one 404 with the output capped at 1,024 characters. The successful result came through and the text still said
Extraction failed for 1 of 2 URLs.All 192 tests and seven CI checks pass, including ESM, CommonJS, and TypeScript compatibility checks.