langchain-findcheap 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.
- langchain_findcheap-0.1.0/LICENSE +21 -0
- langchain_findcheap-0.1.0/MANIFEST.in +2 -0
- langchain_findcheap-0.1.0/PKG-INFO +94 -0
- langchain_findcheap-0.1.0/README.md +71 -0
- langchain_findcheap-0.1.0/pyproject.toml +44 -0
- langchain_findcheap-0.1.0/setup.cfg +4 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap/__init__.py +26 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap/_version.py +3 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap/py.typed +0 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap/tools.py +475 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap.egg-info/PKG-INFO +94 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap.egg-info/SOURCES.txt +17 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap.egg-info/dependency_links.txt +1 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap.egg-info/requires.txt +6 -0
- langchain_findcheap-0.1.0/src/langchain_findcheap.egg-info/top_level.txt +1 -0
- langchain_findcheap-0.1.0/tests/__init__.py +0 -0
- langchain_findcheap-0.1.0/tests/stub.py +98 -0
- langchain_findcheap-0.1.0/tests/test_standard.py +98 -0
- langchain_findcheap-0.1.0/tests/test_tools.py +256 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 llmbender
|
|
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,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-findcheap
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LangChain tools for Findcheap, which finds where a product is sold for less: the same product and its equivalents, cheapest first.
|
|
5
|
+
Author-email: Findcheap <support@findcheap.ai>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://findcheap.ai/developers
|
|
8
|
+
Project-URL: Documentation, https://findcheap.ai/developers/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/llmbender/findcheap-sdks
|
|
10
|
+
Keywords: findcheap,langchain,price comparison,shopping,agents,product search
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: findcheap<1.0.0,>=0.4.0
|
|
18
|
+
Requires-Dist: langchain-core<2.0.0,>=1.4.0
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
21
|
+
Requires-Dist: langchain-tests<2.0.0,>=1.0.0; extra == "test"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# langchain-findcheap
|
|
25
|
+
|
|
26
|
+
Findcheap for LangChain agents: where a product is sold for less. Five tools over the [Findcheap API](https://findcheap.ai/developers/docs), each a thin wrapper around the [`findcheap`](https://pypi.org/project/findcheap/) client. Python 3.10+.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install langchain-findcheap
|
|
30
|
+
export FINDCHEAP_API_KEY=fc_live_... # from https://findcheap.ai/signin?next=/dashboard/keys
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
An account is free: 1,000 credits a month, no card.
|
|
34
|
+
|
|
35
|
+
## Use with an agent
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from langchain.agents import create_agent
|
|
39
|
+
from langchain_findcheap import FindcheapToolkit
|
|
40
|
+
|
|
41
|
+
agent = create_agent("anthropic:claude-sonnet-5-5", tools=FindcheapToolkit().get_tools())
|
|
42
|
+
|
|
43
|
+
result = agent.invoke({"messages": [{"role": "user", "content":
|
|
44
|
+
"Find where this is available for a lower price: https://findcheap.ai/sample-product"}]})
|
|
45
|
+
print(result["messages"][-1].content)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Any chat model that calls tools works. This example also needs `pip install langchain langchain-anthropic` and an `ANTHROPIC_API_KEY`.
|
|
49
|
+
|
|
50
|
+
## The tools
|
|
51
|
+
|
|
52
|
+
| Tool | Class | What it does | Credits |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| `find_cheaper` | `FindcheapFindCheaper` | Finds where the product on a page is sold for less: the same product and acceptable equivalents, cheapest first. Up to 60 seconds. | 10 |
|
|
55
|
+
| `search_products` | `FindcheapSearchProducts` | Finds listings that match a description in words, or a photo's link, cheapest first. | 10 |
|
|
56
|
+
| `read_product_page` | `FindcheapReadProductPage` | Reads what a page sells (title, price, brand, stock), without a search. | 1 |
|
|
57
|
+
| `resolve_listing` | `FindcheapResolveListing` | Gives the merchant's link for a card that came with a `resolve_id`. | 1 when a link came back |
|
|
58
|
+
| `submit_feedback` | `FindcheapSubmitFeedback` | Reports how a search went. The first report on a search gives 1 credit back. | 0 |
|
|
59
|
+
|
|
60
|
+
They carry the names and the descriptions of the tools of Findcheap's MCP server, so an answer's `next_steps` name these tools and their fields.
|
|
61
|
+
|
|
62
|
+
`find_cheaper`, `read_product_page` and `search_products` require `objective`: what the shopper wants, in one sentence. An agent writes it on every call.
|
|
63
|
+
|
|
64
|
+
`submit_feedback` is the one tool that writes: it sends Findcheap a report on a search. To leave it out, build the list yourself:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from langchain_findcheap import FindcheapFindCheaper, FindcheapReadProductPage
|
|
68
|
+
|
|
69
|
+
tools = [FindcheapFindCheaper(), FindcheapReadProductPage()]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Call a tool yourself
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from langchain_findcheap import FindcheapFindCheaper
|
|
76
|
+
|
|
77
|
+
answer = FindcheapFindCheaper().invoke({"url": "https://findcheap.ai/sample-product", "max_results": 3,
|
|
78
|
+
"objective": "These shoes for less, new."})
|
|
79
|
+
print(answer["product"]["title"], answer["page_is_cheapest"])
|
|
80
|
+
for card in answer["same_product"]:
|
|
81
|
+
print(card["price"], card["currency"], card["retailer"], card["url"] or card["resolve_id"])
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A tool answers what the API answers, untouched: every field is in the reference, https://findcheap.ai/developers/docs.md. A call the API refuses (a page that is not a product page, credits used up, a rate limit) reaches the model as the tool's answer, in the API's own words, so the agent can act on it; it does not stop the agent.
|
|
85
|
+
|
|
86
|
+
Each tool and the toolkit take `api_key=` (in place of the environment variable), `timeout=` (seconds, for every call) and `base_url=`.
|
|
87
|
+
|
|
88
|
+
## Tests
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install -e ".[test]" && python -m pytest
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Offline: LangChain's standard tests for tools and this package's own, over a local stub of the API.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# langchain-findcheap
|
|
2
|
+
|
|
3
|
+
Findcheap for LangChain agents: where a product is sold for less. Five tools over the [Findcheap API](https://findcheap.ai/developers/docs), each a thin wrapper around the [`findcheap`](https://pypi.org/project/findcheap/) client. Python 3.10+.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install langchain-findcheap
|
|
7
|
+
export FINDCHEAP_API_KEY=fc_live_... # from https://findcheap.ai/signin?next=/dashboard/keys
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
An account is free: 1,000 credits a month, no card.
|
|
11
|
+
|
|
12
|
+
## Use with an agent
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from langchain.agents import create_agent
|
|
16
|
+
from langchain_findcheap import FindcheapToolkit
|
|
17
|
+
|
|
18
|
+
agent = create_agent("anthropic:claude-sonnet-5-5", tools=FindcheapToolkit().get_tools())
|
|
19
|
+
|
|
20
|
+
result = agent.invoke({"messages": [{"role": "user", "content":
|
|
21
|
+
"Find where this is available for a lower price: https://findcheap.ai/sample-product"}]})
|
|
22
|
+
print(result["messages"][-1].content)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Any chat model that calls tools works. This example also needs `pip install langchain langchain-anthropic` and an `ANTHROPIC_API_KEY`.
|
|
26
|
+
|
|
27
|
+
## The tools
|
|
28
|
+
|
|
29
|
+
| Tool | Class | What it does | Credits |
|
|
30
|
+
|---|---|---|---|
|
|
31
|
+
| `find_cheaper` | `FindcheapFindCheaper` | Finds where the product on a page is sold for less: the same product and acceptable equivalents, cheapest first. Up to 60 seconds. | 10 |
|
|
32
|
+
| `search_products` | `FindcheapSearchProducts` | Finds listings that match a description in words, or a photo's link, cheapest first. | 10 |
|
|
33
|
+
| `read_product_page` | `FindcheapReadProductPage` | Reads what a page sells (title, price, brand, stock), without a search. | 1 |
|
|
34
|
+
| `resolve_listing` | `FindcheapResolveListing` | Gives the merchant's link for a card that came with a `resolve_id`. | 1 when a link came back |
|
|
35
|
+
| `submit_feedback` | `FindcheapSubmitFeedback` | Reports how a search went. The first report on a search gives 1 credit back. | 0 |
|
|
36
|
+
|
|
37
|
+
They carry the names and the descriptions of the tools of Findcheap's MCP server, so an answer's `next_steps` name these tools and their fields.
|
|
38
|
+
|
|
39
|
+
`find_cheaper`, `read_product_page` and `search_products` require `objective`: what the shopper wants, in one sentence. An agent writes it on every call.
|
|
40
|
+
|
|
41
|
+
`submit_feedback` is the one tool that writes: it sends Findcheap a report on a search. To leave it out, build the list yourself:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from langchain_findcheap import FindcheapFindCheaper, FindcheapReadProductPage
|
|
45
|
+
|
|
46
|
+
tools = [FindcheapFindCheaper(), FindcheapReadProductPage()]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Call a tool yourself
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from langchain_findcheap import FindcheapFindCheaper
|
|
53
|
+
|
|
54
|
+
answer = FindcheapFindCheaper().invoke({"url": "https://findcheap.ai/sample-product", "max_results": 3,
|
|
55
|
+
"objective": "These shoes for less, new."})
|
|
56
|
+
print(answer["product"]["title"], answer["page_is_cheapest"])
|
|
57
|
+
for card in answer["same_product"]:
|
|
58
|
+
print(card["price"], card["currency"], card["retailer"], card["url"] or card["resolve_id"])
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A tool answers what the API answers, untouched: every field is in the reference, https://findcheap.ai/developers/docs.md. A call the API refuses (a page that is not a product page, credits used up, a rate limit) reaches the model as the tool's answer, in the API's own words, so the agent can act on it; it does not stop the agent.
|
|
62
|
+
|
|
63
|
+
Each tool and the toolkit take `api_key=` (in place of the environment variable), `timeout=` (seconds, for every call) and `base_url=`.
|
|
64
|
+
|
|
65
|
+
## Tests
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install -e ".[test]" && python -m pytest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Offline: LangChain's standard tests for tools and this package's own, over a local stub of the API.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "langchain-findcheap"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "LangChain tools for Findcheap, which finds where a product is sold for less: the same product and its equivalents, cheapest first."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Findcheap", email = "support@findcheap.ai" }]
|
|
13
|
+
keywords = ["findcheap", "langchain", "price comparison", "shopping", "agents", "product search"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
18
|
+
]
|
|
19
|
+
# The Findcheap client does the calls (standard library only); langchain-core
|
|
20
|
+
# gives the tool classes. The lower bound of langchain-core is the oldest
|
|
21
|
+
# version the tests were run against.
|
|
22
|
+
dependencies = ["findcheap>=0.4.0,<1.0.0", "langchain-core>=1.4.0,<2.0.0"]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
# What the tests need: pytest, and LangChain's own standard tests for tools.
|
|
26
|
+
test = ["pytest>=8", "langchain-tests>=1.0.0,<2.0.0"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://findcheap.ai/developers"
|
|
30
|
+
Documentation = "https://findcheap.ai/developers/docs"
|
|
31
|
+
Repository = "https://github.com/llmbender/findcheap-sdks"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.packages.find]
|
|
34
|
+
where = ["src"]
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.package-data]
|
|
37
|
+
langchain_findcheap = ["py.typed"]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
testpaths = ["tests"]
|
|
41
|
+
# LangChain's standard tests call each tool through its async door too;
|
|
42
|
+
# pytest-asyncio (which comes with langchain-tests) runs those.
|
|
43
|
+
asyncio_mode = "auto"
|
|
44
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""LangChain tools for the Findcheap API: where a product is sold for less.
|
|
2
|
+
|
|
3
|
+
from langchain_findcheap import FindcheapToolkit
|
|
4
|
+
tools = FindcheapToolkit().get_tools() # FINDCHEAP_API_KEY in the environment
|
|
5
|
+
|
|
6
|
+
Reference: https://findcheap.ai/developers/docs.md
|
|
7
|
+
"""
|
|
8
|
+
from langchain_findcheap._version import __version__
|
|
9
|
+
from langchain_findcheap.tools import (
|
|
10
|
+
FindcheapFindCheaper,
|
|
11
|
+
FindcheapReadProductPage,
|
|
12
|
+
FindcheapResolveListing,
|
|
13
|
+
FindcheapSearchProducts,
|
|
14
|
+
FindcheapSubmitFeedback,
|
|
15
|
+
FindcheapToolkit,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"FindcheapFindCheaper",
|
|
20
|
+
"FindcheapReadProductPage",
|
|
21
|
+
"FindcheapResolveListing",
|
|
22
|
+
"FindcheapSearchProducts",
|
|
23
|
+
"FindcheapSubmitFeedback",
|
|
24
|
+
"FindcheapToolkit",
|
|
25
|
+
"__version__",
|
|
26
|
+
]
|
|
File without changes
|