Skip to main content

An integration package connecting SERPEX and LangChain (Python)

Project description

langchain-serpex-python

PyPI - Version PyPI - License Twitter

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"
)

# 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"
)

# 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",
    time_range="month"
)

# 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 - "auto", "google", "bing", "duckduckgo", "brave", "yahoo", "yandex" (default: "auto")
  • category (str): Search category - currently only "web" is supported (default: "web")
  • time_range (str): Time filter - "all", "day", "week", "month", "year" (not supported by Brave)

Documentation

For more detailed documentation, visit:

Support

For issues and questions:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_serpex_python-0.1.5.tar.gz (134.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_serpex_python-0.1.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_serpex_python-0.1.5.tar.gz.

File metadata

  • Download URL: langchain_serpex_python-0.1.5.tar.gz
  • Upload date:
  • Size: 134.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for langchain_serpex_python-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ddd6099763a0966c196beda94670870411b2ee7750413745e8fdb67f63e88d0d
MD5 204f2e251fcc07b673ff92508d31578b
BLAKE2b-256 e4243d83cc8fc2557c0bf835f0b44f5327d1ffd37f1689a14ed5f86b651a5f76

See more details on using hashes here.

File details

Details for the file langchain_serpex_python-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_serpex_python-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e809dd850c08434ac18131443c44add1f21db62a2ef33d35c2d0bbc4974f88d4
MD5 7000ab43451236180c756697e31e62ae
BLAKE2b-256 e6958d84228f2659646ecc430ebca797079c9e98336613e5c47141c88bd7a401

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page