langchain-zerogpu 0.2.1__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,23 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+
7
+ # Build artifacts
8
+ build/
9
+ dist/
10
+
11
+ # Virtual environments
12
+ .venv/
13
+ venv/
14
+
15
+ # Tooling caches
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+ .ruff_cache/
19
+ .coverage
20
+ htmlcov/
21
+
22
+ # OS
23
+ .DS_Store
@@ -0,0 +1,82 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.1] - 2026-06-03
11
+
12
+ First release published to PyPI. The library is unchanged since 0.2.0 — this
13
+ release establishes the automated release pipeline: tagged versions are built,
14
+ published to PyPI via Trusted Publishing (OIDC), and turned into GitHub
15
+ releases whose notes come straight from this changelog.
16
+
17
+ ### Added
18
+
19
+ - CI `changelog` job that fails pull requests changing package code without a
20
+ matching `CHANGELOG.md` update.
21
+
22
+ ### Changed
23
+
24
+ - The `Release` workflow now creates the GitHub release from the matching
25
+ `## [X.Y.Z]` section of this changelog (titled `langchain-zerogpu X.Y.Z`,
26
+ with an install block and the built artifacts attached) instead of
27
+ auto-generated notes, and publishes to PyPI via Trusted Publishing.
28
+
29
+ ## [0.2.0] - 2026-06-02
30
+
31
+ ### Changed
32
+
33
+ - All eleven tools now route through the ZeroGPU Responses API. `ZeroGPUChatTool`
34
+ and `ZeroGPUChatThinkingTool` were migrated off chat completions onto
35
+ `responses.create_response`, so every tool shares one SDK surface; a system
36
+ prompt is carried as a system/user message pair.
37
+ - `__version__` is now derived from the installed distribution metadata via
38
+ `importlib.metadata`, making `pyproject.toml` the single source of truth for
39
+ the version.
40
+ - Adopted the canonical ZeroGPU product description across the package metadata,
41
+ README, and docstrings.
42
+
43
+ ### Removed
44
+
45
+ - `ZeroGPUClient.chat()` / `ZeroGPUClient.achat()` and the chat-completions
46
+ response handling, superseded by the Responses API path.
47
+
48
+ ### Fixed
49
+
50
+ - Corrected the summarize model identifier to `llama-3.1-8b-instruct-fast`
51
+ (previously the hyphenated `llama-3-1-8b-instruct-fast`).
52
+
53
+ ## [0.1.0] - 2026-06-01
54
+
55
+ ### Added
56
+
57
+ - Initial release of `langchain-zerogpu`.
58
+ - Eleven LangChain `BaseTool` subclasses wrapping ZeroGPU small/nano language model tasks:
59
+ - `ZeroGPUChatTool` (`LFM2.5-1.2B-Instruct`)
60
+ - `ZeroGPUChatThinkingTool` (`LFM2.5-1.2B-Thinking`)
61
+ - `ZeroGPUSummarizeTool` (`llama-3.1-8b-instruct-fast`)
62
+ - `ZeroGPUClassifyIABTool` (`zlm-v1-iab-classify-edge`)
63
+ - `ZeroGPUClassifyIABEnrichedTool` (`zlm-v1-iab-classify-edge-enriched`)
64
+ - `ZeroGPUClassifyZeroShotTool` (`deberta-v3-small`)
65
+ - `ZeroGPUClassifyStructuredTool` (`gliner2-base-v1`)
66
+ - `ZeroGPUExtractEntitiesTool` (`gliner2-base-v1`)
67
+ - `ZeroGPUExtractPIITool` (`gliner-multi-pii-v1`)
68
+ - `ZeroGPURedactPIITool` (`gliner-multi-pii-v1`)
69
+ - `ZeroGPUExtractJSONTool` (`gliner2-base-v1`)
70
+ - `ZeroGPUToolkit` bundling all eleven tools behind a single shared client.
71
+ - Credential resolution from constructor arguments or the `ZEROGPU_API_KEY` /
72
+ `ZEROGPU_PROJECT_ID` environment variables, with the API key stored as a
73
+ `pydantic.SecretStr`.
74
+ - Synchronous and asynchronous execution for every tool via the official
75
+ `zerogpu-api` SDK.
76
+ - Clear error messages for authentication (401), access (403), rate-limit
77
+ (429), server (5xx), and network failures.
78
+
79
+ [Unreleased]: https://github.com/zerogpu/langchain-zerogpu/compare/v0.2.1...HEAD
80
+ [0.2.1]: https://github.com/zerogpu/langchain-zerogpu/compare/v0.2.0...v0.2.1
81
+ [0.2.0]: https://github.com/zerogpu/langchain-zerogpu/compare/v0.1.0...v0.2.0
82
+ [0.1.0]: https://github.com/zerogpu/langchain-zerogpu/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZeroGPU
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,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-zerogpu
3
+ Version: 0.2.1
4
+ Summary: LangChain tools for ZeroGPU: A compute-efficient inference provider for apps and agents — purpose-built small and nano language models on an edge network that run the repeatable tasks frontier models shouldn’t, ~10x faster and 50%+ cheaper. Auto-scaling, with zero GPU infrastructure. Plug in and you’re live.
5
+ Project-URL: Homepage, https://github.com/zerogpu/langchain-zerogpu
6
+ Project-URL: Repository, https://github.com/zerogpu/langchain-zerogpu
7
+ Project-URL: Documentation, https://docs.zerogpu.ai
8
+ Project-URL: Changelog, https://github.com/zerogpu/langchain-zerogpu/blob/main/CHANGELOG.md
9
+ Project-URL: Bug Tracker, https://github.com/zerogpu/langchain-zerogpu/issues
10
+ Author-email: ZeroGPU <support@zerogpu.ai>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: classification,langchain,llm,ner,nlp,pii,tools,zerogpu
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: <4.0,>=3.10
24
+ Requires-Dist: langchain-core<2.0.0,>=0.3.0
25
+ Requires-Dist: zerogpu-api<0.2.0,>=0.1.3
26
+ Description-Content-Type: text/markdown
27
+
28
+ # langchain-zerogpu
29
+
30
+ LangChain tools for [ZeroGPU](https://zerogpu.ai).
31
+
32
+ ZeroGPU is a compute-efficient inference provider for apps and agents. We run
33
+ purpose-built small and nano language models across an edge network for the
34
+ high-volume tasks you run constantly — classification, extraction, moderation,
35
+ routing, summarization — at ~10x lower latency and 50%+ lower cost than
36
+ frontier-model workflows. Auto-scaling, with zero GPU infrastructure to manage.
37
+ Plug in and you're live.
38
+
39
+ This package exposes those models as first-class LangChain
40
+ [`BaseTool`](https://python.langchain.com/docs/concepts/tools/) subclasses, so
41
+ any LangChain agent — including `create_agent` and LangGraph graphs — can offload
42
+ these repeatable NLP tasks (classification, summarization, entity / JSON
43
+ extraction, PII redaction, and short chat) to ZeroGPU instead of spending
44
+ frontier-model tokens.
45
+
46
+ All calls go through the official [`zerogpu-api`](https://pypi.org/project/zerogpu-api/)
47
+ Python SDK.
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pip install langchain-zerogpu
53
+ ```
54
+
55
+ ## Authenticate
56
+
57
+ Every request needs a ZeroGPU **API key** (starts with `zgpu-api-`) and a
58
+ **project id**. Provide them via environment variables:
59
+
60
+ ```bash
61
+ export ZEROGPU_API_KEY="zgpu-api-..."
62
+ export ZEROGPU_PROJECT_ID="your-project-id"
63
+ ```
64
+
65
+ …or pass them directly to any tool or the toolkit:
66
+
67
+ ```python
68
+ from langchain_zerogpu import ZeroGPUSummarizeTool
69
+
70
+ tool = ZeroGPUSummarizeTool(api_key="zgpu-api-...", project_id="your-project-id")
71
+ ```
72
+
73
+ The API key is stored as a `pydantic.SecretStr` and is never logged.
74
+
75
+ ## The tools
76
+
77
+ | Tool class | ZeroGPU model | Purpose |
78
+ | --- | --- | --- |
79
+ | `ZeroGPUChatTool` | `LFM2.5-1.2B-Instruct` | Short single-turn chat reply |
80
+ | `ZeroGPUChatThinkingTool` | `LFM2.5-1.2B-Thinking` | Chat with a visible reasoning trace |
81
+ | `ZeroGPUSummarizeTool` | `llama-3.1-8b-instruct-fast` | Condense a passage |
82
+ | `ZeroGPUClassifyIABTool` | `zlm-v1-iab-classify-edge` | IAB taxonomy classification |
83
+ | `ZeroGPUClassifyIABEnrichedTool` | `zlm-v1-iab-classify-edge-enriched` | IAB + topics / keywords / intent |
84
+ | `ZeroGPUClassifyZeroShotTool` | `deberta-v3-small` | Zero-shot vs. custom labels |
85
+ | `ZeroGPUClassifyStructuredTool` | `gliner2-base-v1` | Multi-axis schema classification |
86
+ | `ZeroGPUExtractEntitiesTool` | `gliner2-base-v1` | Custom-label NER |
87
+ | `ZeroGPUExtractPIITool` | `gliner-multi-pii-v1` | Extract PII entities (JSON) |
88
+ | `ZeroGPURedactPIITool` | `gliner-multi-pii-v1` | Mask PII inline with `[LABEL]` |
89
+ | `ZeroGPUExtractJSONTool` | `gliner2-base-v1` | Schema-driven JSON extraction |
90
+
91
+ ## Quick start
92
+
93
+ ```python
94
+ from langchain_zerogpu import ZeroGPUClassifyZeroShotTool
95
+
96
+ tool = ZeroGPUClassifyZeroShotTool() # reads creds from the environment
97
+
98
+ print(tool.invoke({
99
+ "text": "The new GPU smashes every benchmark we threw at it.",
100
+ "labels": ["tech", "politics", "sports"],
101
+ }))
102
+ ```
103
+
104
+ Tools work asynchronously too:
105
+
106
+ ```python
107
+ result = await tool.ainvoke({"text": "...", "labels": ["a", "b"]})
108
+ ```
109
+
110
+ ## Bind the tools to an agent
111
+
112
+ Use the toolkit to get all eleven tools — wired to a single shared client — and
113
+ bind them to an agent:
114
+
115
+ ```python
116
+ from langchain.agents import create_agent
117
+ from langchain_zerogpu import ZeroGPUToolkit
118
+
119
+ toolkit = ZeroGPUToolkit() # reads ZEROGPU_API_KEY / ZEROGPU_PROJECT_ID
120
+ tools = toolkit.get_tools()
121
+
122
+ agent = create_agent("anthropic:claude-sonnet-4-6", tools=tools)
123
+
124
+ agent.invoke({
125
+ "messages": [
126
+ {"role": "user", "content": "Redact the PII in: 'Call Jane at 555-0100.'"}
127
+ ]
128
+ })
129
+ ```
130
+
131
+ Or bind a single tool to a chat model directly:
132
+
133
+ ```python
134
+ from langchain.chat_models import init_chat_model
135
+ from langchain_zerogpu import ZeroGPUExtractPIITool
136
+
137
+ llm = init_chat_model("anthropic:claude-sonnet-4-6")
138
+ llm_with_tools = llm.bind_tools([ZeroGPUExtractPIITool()])
139
+ ```
140
+
141
+ ## Errors
142
+
143
+ Failures surface as clear, typed exceptions instead of raw stack traces:
144
+
145
+ - `ZeroGPUAuthError` — missing / malformed credentials, `401`, or `403`.
146
+ - `ZeroGPUError` — rate limits (`429`), server errors (`5xx`), and network
147
+ failures.
148
+
149
+ ## Development
150
+
151
+ ```bash
152
+ make install # uv sync --all-groups
153
+ make lint # ruff check + format --check
154
+ make mypy # mypy (disallow_untyped_defs)
155
+ make test # unit tests, sockets disabled
156
+ make integration_test # integration tests (needs real ZeroGPU creds)
157
+ ```
158
+
159
+ ## License
160
+
161
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,134 @@
1
+ # langchain-zerogpu
2
+
3
+ LangChain tools for [ZeroGPU](https://zerogpu.ai).
4
+
5
+ ZeroGPU is a compute-efficient inference provider for apps and agents. We run
6
+ purpose-built small and nano language models across an edge network for the
7
+ high-volume tasks you run constantly — classification, extraction, moderation,
8
+ routing, summarization — at ~10x lower latency and 50%+ lower cost than
9
+ frontier-model workflows. Auto-scaling, with zero GPU infrastructure to manage.
10
+ Plug in and you're live.
11
+
12
+ This package exposes those models as first-class LangChain
13
+ [`BaseTool`](https://python.langchain.com/docs/concepts/tools/) subclasses, so
14
+ any LangChain agent — including `create_agent` and LangGraph graphs — can offload
15
+ these repeatable NLP tasks (classification, summarization, entity / JSON
16
+ extraction, PII redaction, and short chat) to ZeroGPU instead of spending
17
+ frontier-model tokens.
18
+
19
+ All calls go through the official [`zerogpu-api`](https://pypi.org/project/zerogpu-api/)
20
+ Python SDK.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install langchain-zerogpu
26
+ ```
27
+
28
+ ## Authenticate
29
+
30
+ Every request needs a ZeroGPU **API key** (starts with `zgpu-api-`) and a
31
+ **project id**. Provide them via environment variables:
32
+
33
+ ```bash
34
+ export ZEROGPU_API_KEY="zgpu-api-..."
35
+ export ZEROGPU_PROJECT_ID="your-project-id"
36
+ ```
37
+
38
+ …or pass them directly to any tool or the toolkit:
39
+
40
+ ```python
41
+ from langchain_zerogpu import ZeroGPUSummarizeTool
42
+
43
+ tool = ZeroGPUSummarizeTool(api_key="zgpu-api-...", project_id="your-project-id")
44
+ ```
45
+
46
+ The API key is stored as a `pydantic.SecretStr` and is never logged.
47
+
48
+ ## The tools
49
+
50
+ | Tool class | ZeroGPU model | Purpose |
51
+ | --- | --- | --- |
52
+ | `ZeroGPUChatTool` | `LFM2.5-1.2B-Instruct` | Short single-turn chat reply |
53
+ | `ZeroGPUChatThinkingTool` | `LFM2.5-1.2B-Thinking` | Chat with a visible reasoning trace |
54
+ | `ZeroGPUSummarizeTool` | `llama-3.1-8b-instruct-fast` | Condense a passage |
55
+ | `ZeroGPUClassifyIABTool` | `zlm-v1-iab-classify-edge` | IAB taxonomy classification |
56
+ | `ZeroGPUClassifyIABEnrichedTool` | `zlm-v1-iab-classify-edge-enriched` | IAB + topics / keywords / intent |
57
+ | `ZeroGPUClassifyZeroShotTool` | `deberta-v3-small` | Zero-shot vs. custom labels |
58
+ | `ZeroGPUClassifyStructuredTool` | `gliner2-base-v1` | Multi-axis schema classification |
59
+ | `ZeroGPUExtractEntitiesTool` | `gliner2-base-v1` | Custom-label NER |
60
+ | `ZeroGPUExtractPIITool` | `gliner-multi-pii-v1` | Extract PII entities (JSON) |
61
+ | `ZeroGPURedactPIITool` | `gliner-multi-pii-v1` | Mask PII inline with `[LABEL]` |
62
+ | `ZeroGPUExtractJSONTool` | `gliner2-base-v1` | Schema-driven JSON extraction |
63
+
64
+ ## Quick start
65
+
66
+ ```python
67
+ from langchain_zerogpu import ZeroGPUClassifyZeroShotTool
68
+
69
+ tool = ZeroGPUClassifyZeroShotTool() # reads creds from the environment
70
+
71
+ print(tool.invoke({
72
+ "text": "The new GPU smashes every benchmark we threw at it.",
73
+ "labels": ["tech", "politics", "sports"],
74
+ }))
75
+ ```
76
+
77
+ Tools work asynchronously too:
78
+
79
+ ```python
80
+ result = await tool.ainvoke({"text": "...", "labels": ["a", "b"]})
81
+ ```
82
+
83
+ ## Bind the tools to an agent
84
+
85
+ Use the toolkit to get all eleven tools — wired to a single shared client — and
86
+ bind them to an agent:
87
+
88
+ ```python
89
+ from langchain.agents import create_agent
90
+ from langchain_zerogpu import ZeroGPUToolkit
91
+
92
+ toolkit = ZeroGPUToolkit() # reads ZEROGPU_API_KEY / ZEROGPU_PROJECT_ID
93
+ tools = toolkit.get_tools()
94
+
95
+ agent = create_agent("anthropic:claude-sonnet-4-6", tools=tools)
96
+
97
+ agent.invoke({
98
+ "messages": [
99
+ {"role": "user", "content": "Redact the PII in: 'Call Jane at 555-0100.'"}
100
+ ]
101
+ })
102
+ ```
103
+
104
+ Or bind a single tool to a chat model directly:
105
+
106
+ ```python
107
+ from langchain.chat_models import init_chat_model
108
+ from langchain_zerogpu import ZeroGPUExtractPIITool
109
+
110
+ llm = init_chat_model("anthropic:claude-sonnet-4-6")
111
+ llm_with_tools = llm.bind_tools([ZeroGPUExtractPIITool()])
112
+ ```
113
+
114
+ ## Errors
115
+
116
+ Failures surface as clear, typed exceptions instead of raw stack traces:
117
+
118
+ - `ZeroGPUAuthError` — missing / malformed credentials, `401`, or `403`.
119
+ - `ZeroGPUError` — rate limits (`429`), server errors (`5xx`), and network
120
+ failures.
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ make install # uv sync --all-groups
126
+ make lint # ruff check + format --check
127
+ make mypy # mypy (disallow_untyped_defs)
128
+ make test # unit tests, sockets disabled
129
+ make integration_test # integration tests (needs real ZeroGPU creds)
130
+ ```
131
+
132
+ ## License
133
+
134
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,59 @@
1
+ """LangChain tools for ZeroGPU.
2
+
3
+ ZeroGPU is a compute-efficient inference provider for apps and agents. It runs
4
+ purpose-built small and nano language models across an edge network for the
5
+ high-volume tasks you run constantly -- classification, extraction, moderation,
6
+ routing, summarization -- at ~10x lower latency and 50%+ lower cost than
7
+ frontier-model workflows.
8
+
9
+ This package exposes the eleven ZeroGPU task models -- chat, summarization,
10
+ classification, entity / JSON extraction, and PII extraction / redaction -- as
11
+ first-class LangChain :class:`~langchain_core.tools.BaseTool` subclasses, plus a
12
+ :class:`ZeroGPUToolkit` that bundles them behind a single shared client.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ from importlib.metadata import PackageNotFoundError, version
18
+
19
+ from langchain_zerogpu._client import ZeroGPUAuthError, ZeroGPUClient, ZeroGPUError
20
+ from langchain_zerogpu.toolkit import ZeroGPUToolkit
21
+ from langchain_zerogpu.tools import (
22
+ ZeroGPUChatThinkingTool,
23
+ ZeroGPUChatTool,
24
+ ZeroGPUClassifyIABEnrichedTool,
25
+ ZeroGPUClassifyIABTool,
26
+ ZeroGPUClassifyStructuredTool,
27
+ ZeroGPUClassifyZeroShotTool,
28
+ ZeroGPUExtractEntitiesTool,
29
+ ZeroGPUExtractJSONTool,
30
+ ZeroGPUExtractPIITool,
31
+ ZeroGPURedactPIITool,
32
+ ZeroGPUSummarizeTool,
33
+ )
34
+
35
+ try:
36
+ # Single source of truth: the version declared in pyproject.toml and
37
+ # baked into the installed distribution's metadata. Avoids drift between
38
+ # this module and pyproject.
39
+ __version__ = version("langchain-zerogpu")
40
+ except PackageNotFoundError: # pragma: no cover - running from a source tree
41
+ __version__ = "0.0.0"
42
+
43
+ __all__ = [
44
+ "ZeroGPUChatTool",
45
+ "ZeroGPUChatThinkingTool",
46
+ "ZeroGPUSummarizeTool",
47
+ "ZeroGPUClassifyIABTool",
48
+ "ZeroGPUClassifyIABEnrichedTool",
49
+ "ZeroGPUClassifyZeroShotTool",
50
+ "ZeroGPUClassifyStructuredTool",
51
+ "ZeroGPUExtractEntitiesTool",
52
+ "ZeroGPUExtractPIITool",
53
+ "ZeroGPURedactPIITool",
54
+ "ZeroGPUExtractJSONTool",
55
+ "ZeroGPUToolkit",
56
+ "ZeroGPUClient",
57
+ "ZeroGPUAuthError",
58
+ "ZeroGPUError",
59
+ ]