ParallelWeb integration for LangChain
Project description
langchain-parallel-web
LangChain tool and toolkit for Parallel Web search. It exposes a tool that performs web research and returns ranked, compressed excerpts from multiple sources, plus a toolkit to easily wire it into agents.
Installation
pip install -U langchain-parallel-web
Set your Parallel API key:
export PARALLEL_API_KEY="your-api-key"
You can also pass the key directly to the classes shown below.
Tool: Parallel Web Search
ParallelWebTool exposes the Parallel Web search as a LangChain tool.
from langchain_parallel_web.tools import ParallelWebTool
# Option 1: rely on PARALLEL_API_KEY in env
tool = ParallelWebTool()
# Option 2: pass the key explicitly
# tool = ParallelWebTool(parallel_api_key="your-api-key")
result_json = tool.invoke({
"objective": "Find when the UN was founded; prefer official sources.",
"search_queries": [
"United Nations founding year",
"When was the UN founded official site"
],
})
print(result_json)
Configuration
You can control search behavior via ParallelWebSearchConfig.
from langchain_parallel_web.parallel_web_wrapper import ParallelWebSearchConfig
from langchain_parallel_web.tools import ParallelWebTool
config = ParallelWebSearchConfig(
max_results=10, # up to 40
processor="base", # or "pro"
max_chars_per_result=1500
)
tool = ParallelWebTool(config=config)
Toolkit: Agent Integration
ParallelWebToolkit returns a ready-to-use list of tools for agent setups.
from langchain_parallel_web.toolkits import ParallelWebToolkit
# Pass the key explicitly for the toolkit
toolkit = ParallelWebToolkit(parallel_api_key="your-api-key")
tools = toolkit.get_tools()
# Use `tools` with your LangChain agent or runnable graph
Direct API Wrapper
For lower-level control, call the wrapper directly.
from langchain_parallel_web.parallel_web_wrapper import (
ParallelWebAPIWrapper,
ParallelWebSearchInput,
)
wrapper = ParallelWebAPIWrapper() # uses PARALLEL_API_KEY from env
# or: wrapper = ParallelWebAPIWrapper(parallel_api_key="your-api-key")
payload = ParallelWebSearchInput(
objective="Summarize key announcements from OpenAI DevDay 2023.",
search_queries=["OpenAI DevDay 2023 announcements", "OpenAI DevDay keynote summary"],
)
out = wrapper.search(payload)
print(out.model_dump())
Async usage is supported:
import asyncio
from langchain_parallel_web.parallel_web_wrapper import (
ParallelWebAPIWrapper,
ParallelWebSearchInput,
)
async def main():
wrapper = ParallelWebAPIWrapper()
out = await wrapper.asearch(
ParallelWebSearchInput(
objective="Latest SEC filing summary for NVDA.",
search_queries=["NVIDIA latest 10-Q", "NVDA SEC filing"],
)
)
print(out.model_dump())
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_parallel_web-0.0.1a0.tar.gz.
File metadata
- Download URL: langchain_parallel_web-0.0.1a0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.16 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47f856862877005fca7acf40041bd4b696ecd7c5535f5c276a10df2b61b0d5f
|
|
| MD5 |
82249a047e8edc79c08e2f42ed3cdbf7
|
|
| BLAKE2b-256 |
9b32118883fbe8458516e5c5514c5033e07782f82d5f14c09b8d67d4e25cde9e
|
File details
Details for the file langchain_parallel_web-0.0.1a0-py3-none-any.whl.
File metadata
- Download URL: langchain_parallel_web-0.0.1a0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.10.16 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f813b535116d8b4517fc65ee9bba47121cd5a89a1658093f2278e768584df62
|
|
| MD5 |
ba8a2abdb115f493997ec086d814c759
|
|
| BLAKE2b-256 |
539a8a53592602faf2c3f469f71250d28da2fa4095cc714ab27af926133dfa48
|