An integration package connecting SERPEX and LangChain (Python)
Project description
langchain-serpex-python
This package contains the LangChain integration with SERPEX (Python).
Installation
pip install langchain-serpex-python
What is SERPEX?
SERPEX is a powerful multi-engine search API that provides access to search results from Google, Bing, DuckDuckGo, Baidu, Yandex, and other search engines in JSON format. It's designed for developers building AI applications, SEO tools, market research platforms, and data aggregation services.
Features
- Multi-Engine Support: Search across Google, Bing, DuckDuckGo, Baidu, and Yandex
- Rich Results: Get organic results, answer boxes, knowledge graphs, news, images, videos, and shopping results
- Localization: Support for location-based and language-specific searches
- Real-time Data: Access to current search results
- Easy Integration: Simple API with comprehensive documentation
Quick Start
Get Your API Key
Sign up at SERPEX to get your API key.
Basic Usage
from langchain_serpex_python import SerpexSearchResults
# Initialize the tool
tool = SerpexSearchResults(
api_key="your-serpex-api-key",
engine="google",
num_results=10
)
# Perform a search
results = tool.invoke("latest AI developments")
print(results)
With Agents
from langchain_serpex_python import SerpexSearchResults
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
# Initialize the search tool
search_tool = SerpexSearchResults(
api_key="your-serpex-api-key",
engine="google",
num_results=5
)
# Initialize the LLM
llm = ChatOpenAI(temperature=0)
# Create an agent with the search tool
agent = initialize_agent(
tools=[search_tool],
llm=llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
# Run the agent
result = agent.run("What are the latest developments in quantum computing?")
print(result)
Advanced Configuration
from langchain_serpex_python import SerpexSearchResults
# Configure with advanced parameters
tool = SerpexSearchResults(
api_key="your-serpex-api-key",
engine="google",
num_results=20,
gl="us", # Country code
hl="en", # Language code
location="New York", # Specific location
time_period="m", # Results from past month
safe_search="moderate"
)
# Search for location-specific results
results = tool.invoke("best restaurants")
print(results)
Different Search Engines
from langchain_serpex_python import SerpexSearchResults
# Google Search
google_tool = SerpexSearchResults(api_key="your-key", engine="google")
google_results = google_tool.invoke("Python programming")
# Bing Search
bing_tool = SerpexSearchResults(api_key="your-key", engine="bing")
bing_results = bing_tool.invoke("Python programming")
# DuckDuckGo Search
ddg_tool = SerpexSearchResults(api_key="your-key", engine="duckduckgo")
ddg_results = ddg_tool.invoke("Python programming")
Configuration
Environment Variables
You can set your SERPEX API key as an environment variable:
export SERPEX_API_KEY="your-serpex-api-key"
Then use the tool without passing the API key:
from langchain_serpex_python import SerpexSearchResults
tool = SerpexSearchResults() # Will use SERPEX_API_KEY from environment
Parameters
api_key(str): Your SERPEX API key (required)engine(str): Search engine to use - "google", "bing", "duckduckgo", "baidu", "yandex" (default: "google")num_results(int): Number of results to return, 1-100 (default: 10)gl(str): Country code for localized results (e.g., "us", "uk", "ca")hl(str): Language code (e.g., "en", "es", "fr")location(str): Specific location for localized resultstime_period(str): Time filter - "d" (day), "w" (week), "m" (month), "y" (year)safe_search(str): Safe search filter - "off", "moderate", "strict"
Documentation
For more detailed documentation, visit:
Support
For issues and questions:
- GitHub Issues: langchain-serpex issues
- SERPEX Support: support@serpex.dev
License
This package is licensed under the MIT License.
CI / Publishing
A GitHub Actions workflow is provided to publish the package to PyPI when a tag like v* is pushed or when a release is published.
Required repository secret:
PYPI_API_TOKEN— a PyPI API token with permission to upload the package. Set this in the repository's Settings → Secrets → Actions.
To publish a new release, create a tag vMAJOR.MINOR.PATCH and push it or create a release in GitHub; the workflow will build sdist and wheel and upload them to PyPI.
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_serpex_python-0.1.0.tar.gz.
File metadata
- Download URL: langchain_serpex_python-0.1.0.tar.gz
- Upload date:
- Size: 134.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d696c3db550ec7cf9b1520d62728ff88d93ec4d8c0fcafba34190ff7d1a6024
|
|
| MD5 |
43615e8d3c2ea9afe619fa549bb91b69
|
|
| BLAKE2b-256 |
61bfeb5a878bc508b6e6584c1b91c49739772f19032ffe51a5c0fe884b640173
|
File details
Details for the file langchain_serpex_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_serpex_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3525983b5e9e9dc4056769519bc702c1177b248f6aa9ee9ed388e323bfcb6a78
|
|
| MD5 |
fd8eb4f4bf955a58e86a55cf2d6d3f55
|
|
| BLAKE2b-256 |
5788168f6df89186b7dbe6488671df1725d32105a49a7bc3609b626b9c5b34d9
|