langchain-serpex-python 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ release:
8
+ types: [published]
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ publish:
13
+ name: Build and publish
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: '3.11'
23
+
24
+ - name: Install build tools
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install build twine
28
+
29
+ - name: Build distributions
30
+ run: |
31
+ python -m build --sdist --wheel
32
+
33
+ - name: Publish to PyPI
34
+ if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')
35
+ env:
36
+ TWINE_USERNAME: __token__
37
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
38
+ run: |
39
+ python -m twine upload dist/*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 LangChain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,60 @@
1
+ .PHONY: all format lint test tests integration_tests help extended_tests
2
+
3
+ # Default target executed when no arguments are given to make.
4
+ all: help
5
+
6
+ .EXPORT_ALL_VARIABLES:
7
+ UV_FROZEN = true
8
+
9
+ # Define a variable for the test file path.
10
+ TEST_FILE ?= tests/unit_tests/
11
+ integration_test integration_tests: TEST_FILE = tests/integration_tests/
12
+
13
+ test tests:
14
+ uv run --group test pytest --disable-socket --allow-unix-socket $(TEST_FILE)
15
+
16
+ integration_test integration_tests:
17
+ uv run --group test --group test_integration pytest $(TEST_FILE)
18
+
19
+ test_watch:
20
+ uv run --group test ptw --snapshot-update --now . -- -vv $(TEST_FILE)
21
+
22
+
23
+
24
+ ######################
25
+ # LINTING AND FORMATTING
26
+ ######################
27
+
28
+ # Define a variable for Python and notebook files.
29
+ PYTHON_FILES=.
30
+ MYPY_CACHE=.mypy_cache
31
+ lint format: PYTHON_FILES=.
32
+ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/partners/serpex --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
33
+ lint_package: PYTHON_FILES=langchain_serpex
34
+ lint_tests: PYTHON_FILES=tests
35
+ lint_tests: MYPY_CACHE=.mypy_cache_test
36
+
37
+ lint lint_diff lint_package lint_tests:
38
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES)
39
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff
40
+ [ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
41
+
42
+ format format_diff:
43
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES)
44
+ [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES)
45
+
46
+ check_imports: $(shell find langchain_serpex -name '*.py')
47
+ uv run --all-groups python ./scripts/check_imports.py $^
48
+
49
+ ######################
50
+ # HELP
51
+ ######################
52
+
53
+ help:
54
+ @echo '----'
55
+ @echo 'check_imports - check imports'
56
+ @echo 'format - run code formatters'
57
+ @echo 'lint - run linters'
58
+ @echo 'test - run unit tests'
59
+ @echo 'tests - run unit tests'
60
+ @echo 'test TEST_FILE=<test_file> - run all tests in file'
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-serpex-python
3
+ Version: 0.1.0
4
+ Summary: An integration package connecting SERPEX and LangChain (Python)
5
+ Project-URL: Homepage, https://docs.langchain.com/oss/python/integrations/providers/serpex
6
+ Project-URL: Documentation, https://serpex.dev/docs
7
+ Project-URL: Source, https://github.com/divyeshradadiya/langchain-serpex
8
+ Project-URL: Repository, https://github.com/divyeshradadiya/langchain-serpex
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Requires-Python: <4.0.0,>=3.10.0
12
+ Requires-Dist: httpx>=0.27.0
13
+ Requires-Dist: langchain-core<2.0.0,>=1.0.0
14
+ Description-Content-Type: text/markdown
15
+
16
+ # langchain-serpex-python
17
+
18
+ [![PyPI - Version](https://img.shields.io/pypi/v/langchain-serpex-python?label=%20)](https://pypi.org/project/langchain-serpex-python/#history)
19
+ [![PyPI - License](https://img.shields.io/pypi/l/langchain-serpex-python)](https://opensource.org/licenses/MIT)
20
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
21
+
22
+ This package contains the LangChain integration with SERPEX (Python).
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install langchain-serpex-python
28
+ ```
29
+
30
+ ## What is SERPEX?
31
+
32
+ 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.
33
+
34
+ ## Features
35
+
36
+ - **Multi-Engine Support**: Search across Google, Bing, DuckDuckGo, Baidu, and Yandex
37
+ - **Rich Results**: Get organic results, answer boxes, knowledge graphs, news, images, videos, and shopping results
38
+ - **Localization**: Support for location-based and language-specific searches
39
+ - **Real-time Data**: Access to current search results
40
+ - **Easy Integration**: Simple API with comprehensive documentation
41
+
42
+ ## Quick Start
43
+
44
+ ### Get Your API Key
45
+
46
+ Sign up at [SERPEX](https://serpex.dev) to get your API key.
47
+
48
+ ### Basic Usage
49
+
50
+ ```python
51
+ from langchain_serpex_python import SerpexSearchResults
52
+
53
+ # Initialize the tool
54
+ tool = SerpexSearchResults(
55
+ api_key="your-serpex-api-key",
56
+ engine="google",
57
+ num_results=10
58
+ )
59
+
60
+ # Perform a search
61
+ results = tool.invoke("latest AI developments")
62
+ print(results)
63
+ ```
64
+
65
+ ### With Agents
66
+
67
+ ```python
68
+ from langchain_serpex_python import SerpexSearchResults
69
+ from langchain_openai import ChatOpenAI
70
+ from langchain.agents import initialize_agent, AgentType
71
+
72
+ # Initialize the search tool
73
+ search_tool = SerpexSearchResults(
74
+ api_key="your-serpex-api-key",
75
+ engine="google",
76
+ num_results=5
77
+ )
78
+
79
+ # Initialize the LLM
80
+ llm = ChatOpenAI(temperature=0)
81
+
82
+ # Create an agent with the search tool
83
+ agent = initialize_agent(
84
+ tools=[search_tool],
85
+ llm=llm,
86
+ agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
87
+ verbose=True
88
+ )
89
+
90
+ # Run the agent
91
+ result = agent.run("What are the latest developments in quantum computing?")
92
+ print(result)
93
+ ```
94
+
95
+ ### Advanced Configuration
96
+
97
+ ```python
98
+ from langchain_serpex_python import SerpexSearchResults
99
+
100
+ # Configure with advanced parameters
101
+ tool = SerpexSearchResults(
102
+ api_key="your-serpex-api-key",
103
+ engine="google",
104
+ num_results=20,
105
+ gl="us", # Country code
106
+ hl="en", # Language code
107
+ location="New York", # Specific location
108
+ time_period="m", # Results from past month
109
+ safe_search="moderate"
110
+ )
111
+
112
+ # Search for location-specific results
113
+ results = tool.invoke("best restaurants")
114
+ print(results)
115
+ ```
116
+
117
+ ### Different Search Engines
118
+
119
+ ```python
120
+ from langchain_serpex_python import SerpexSearchResults
121
+
122
+ # Google Search
123
+ google_tool = SerpexSearchResults(api_key="your-key", engine="google")
124
+ google_results = google_tool.invoke("Python programming")
125
+
126
+ # Bing Search
127
+ bing_tool = SerpexSearchResults(api_key="your-key", engine="bing")
128
+ bing_results = bing_tool.invoke("Python programming")
129
+
130
+ # DuckDuckGo Search
131
+ ddg_tool = SerpexSearchResults(api_key="your-key", engine="duckduckgo")
132
+ ddg_results = ddg_tool.invoke("Python programming")
133
+ ```
134
+
135
+ ## Configuration
136
+
137
+ ### Environment Variables
138
+
139
+ You can set your SERPEX API key as an environment variable:
140
+
141
+ ```bash
142
+ export SERPEX_API_KEY="your-serpex-api-key"
143
+ ```
144
+
145
+ Then use the tool without passing the API key:
146
+
147
+ ```python
148
+ from langchain_serpex_python import SerpexSearchResults
149
+
150
+ tool = SerpexSearchResults() # Will use SERPEX_API_KEY from environment
151
+ ```
152
+
153
+ ### Parameters
154
+
155
+ - `api_key` (str): Your SERPEX API key (required)
156
+ - `engine` (str): Search engine to use - "google", "bing", "duckduckgo", "baidu", "yandex" (default: "google")
157
+ - `num_results` (int): Number of results to return, 1-100 (default: 10)
158
+ - `gl` (str): Country code for localized results (e.g., "us", "uk", "ca")
159
+ - `hl` (str): Language code (e.g., "en", "es", "fr")
160
+ - `location` (str): Specific location for localized results
161
+ - `time_period` (str): Time filter - "d" (day), "w" (week), "m" (month), "y" (year)
162
+ - `safe_search` (str): Safe search filter - "off", "moderate", "strict"
163
+
164
+ ## Documentation
165
+
166
+ For more detailed documentation, visit:
167
+ - [LangChain Documentation](https://python.langchain.com)
168
+ - [SERPEX API Documentation](https://serpex.dev/docs)
169
+
170
+ ## Support
171
+
172
+ For issues and questions:
173
+ - GitHub Issues: [langchain-serpex issues](https://github.com/langchain-ai/langchain/issues)
174
+ - SERPEX Support: [support@serpex.dev](mailto:support@serpex.dev)
175
+
176
+ ## License
177
+
178
+ This package is licensed under the MIT License.
179
+
180
+ ## CI / Publishing
181
+
182
+ 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.
183
+
184
+ Required repository secret:
185
+ - `PYPI_API_TOKEN` — a PyPI API token with permission to upload the package. Set this in the repository's Settings → Secrets → Actions.
186
+
187
+ 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.
@@ -0,0 +1,172 @@
1
+ # langchain-serpex-python
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/langchain-serpex-python?label=%20)](https://pypi.org/project/langchain-serpex-python/#history)
4
+ [![PyPI - License](https://img.shields.io/pypi/l/langchain-serpex-python)](https://opensource.org/licenses/MIT)
5
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
6
+
7
+ This package contains the LangChain integration with SERPEX (Python).
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install langchain-serpex-python
13
+ ```
14
+
15
+ ## What is SERPEX?
16
+
17
+ 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.
18
+
19
+ ## Features
20
+
21
+ - **Multi-Engine Support**: Search across Google, Bing, DuckDuckGo, Baidu, and Yandex
22
+ - **Rich Results**: Get organic results, answer boxes, knowledge graphs, news, images, videos, and shopping results
23
+ - **Localization**: Support for location-based and language-specific searches
24
+ - **Real-time Data**: Access to current search results
25
+ - **Easy Integration**: Simple API with comprehensive documentation
26
+
27
+ ## Quick Start
28
+
29
+ ### Get Your API Key
30
+
31
+ Sign up at [SERPEX](https://serpex.dev) to get your API key.
32
+
33
+ ### Basic Usage
34
+
35
+ ```python
36
+ from langchain_serpex_python import SerpexSearchResults
37
+
38
+ # Initialize the tool
39
+ tool = SerpexSearchResults(
40
+ api_key="your-serpex-api-key",
41
+ engine="google",
42
+ num_results=10
43
+ )
44
+
45
+ # Perform a search
46
+ results = tool.invoke("latest AI developments")
47
+ print(results)
48
+ ```
49
+
50
+ ### With Agents
51
+
52
+ ```python
53
+ from langchain_serpex_python import SerpexSearchResults
54
+ from langchain_openai import ChatOpenAI
55
+ from langchain.agents import initialize_agent, AgentType
56
+
57
+ # Initialize the search tool
58
+ search_tool = SerpexSearchResults(
59
+ api_key="your-serpex-api-key",
60
+ engine="google",
61
+ num_results=5
62
+ )
63
+
64
+ # Initialize the LLM
65
+ llm = ChatOpenAI(temperature=0)
66
+
67
+ # Create an agent with the search tool
68
+ agent = initialize_agent(
69
+ tools=[search_tool],
70
+ llm=llm,
71
+ agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
72
+ verbose=True
73
+ )
74
+
75
+ # Run the agent
76
+ result = agent.run("What are the latest developments in quantum computing?")
77
+ print(result)
78
+ ```
79
+
80
+ ### Advanced Configuration
81
+
82
+ ```python
83
+ from langchain_serpex_python import SerpexSearchResults
84
+
85
+ # Configure with advanced parameters
86
+ tool = SerpexSearchResults(
87
+ api_key="your-serpex-api-key",
88
+ engine="google",
89
+ num_results=20,
90
+ gl="us", # Country code
91
+ hl="en", # Language code
92
+ location="New York", # Specific location
93
+ time_period="m", # Results from past month
94
+ safe_search="moderate"
95
+ )
96
+
97
+ # Search for location-specific results
98
+ results = tool.invoke("best restaurants")
99
+ print(results)
100
+ ```
101
+
102
+ ### Different Search Engines
103
+
104
+ ```python
105
+ from langchain_serpex_python import SerpexSearchResults
106
+
107
+ # Google Search
108
+ google_tool = SerpexSearchResults(api_key="your-key", engine="google")
109
+ google_results = google_tool.invoke("Python programming")
110
+
111
+ # Bing Search
112
+ bing_tool = SerpexSearchResults(api_key="your-key", engine="bing")
113
+ bing_results = bing_tool.invoke("Python programming")
114
+
115
+ # DuckDuckGo Search
116
+ ddg_tool = SerpexSearchResults(api_key="your-key", engine="duckduckgo")
117
+ ddg_results = ddg_tool.invoke("Python programming")
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ ### Environment Variables
123
+
124
+ You can set your SERPEX API key as an environment variable:
125
+
126
+ ```bash
127
+ export SERPEX_API_KEY="your-serpex-api-key"
128
+ ```
129
+
130
+ Then use the tool without passing the API key:
131
+
132
+ ```python
133
+ from langchain_serpex_python import SerpexSearchResults
134
+
135
+ tool = SerpexSearchResults() # Will use SERPEX_API_KEY from environment
136
+ ```
137
+
138
+ ### Parameters
139
+
140
+ - `api_key` (str): Your SERPEX API key (required)
141
+ - `engine` (str): Search engine to use - "google", "bing", "duckduckgo", "baidu", "yandex" (default: "google")
142
+ - `num_results` (int): Number of results to return, 1-100 (default: 10)
143
+ - `gl` (str): Country code for localized results (e.g., "us", "uk", "ca")
144
+ - `hl` (str): Language code (e.g., "en", "es", "fr")
145
+ - `location` (str): Specific location for localized results
146
+ - `time_period` (str): Time filter - "d" (day), "w" (week), "m" (month), "y" (year)
147
+ - `safe_search` (str): Safe search filter - "off", "moderate", "strict"
148
+
149
+ ## Documentation
150
+
151
+ For more detailed documentation, visit:
152
+ - [LangChain Documentation](https://python.langchain.com)
153
+ - [SERPEX API Documentation](https://serpex.dev/docs)
154
+
155
+ ## Support
156
+
157
+ For issues and questions:
158
+ - GitHub Issues: [langchain-serpex issues](https://github.com/langchain-ai/langchain/issues)
159
+ - SERPEX Support: [support@serpex.dev](mailto:support@serpex.dev)
160
+
161
+ ## License
162
+
163
+ This package is licensed under the MIT License.
164
+
165
+ ## CI / Publishing
166
+
167
+ 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.
168
+
169
+ Required repository secret:
170
+ - `PYPI_API_TOKEN` — a PyPI API token with permission to upload the package. Set this in the repository's Settings → Secrets → Actions.
171
+
172
+ 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.
@@ -0,0 +1,10 @@
1
+ """SERPEX integration for LangChain.
2
+
3
+ This module provides tools for searching the web using the SERPEX API,
4
+ which supports multiple search engines including Google, Bing, DuckDuckGo,
5
+ Baidu, and Yandex.
6
+ """
7
+
8
+ from langchain_serpex_python.tools import SerpexSearchResults
9
+
10
+ __all__ = ["SerpexSearchResults"]
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561