zerogpu-cli 1.0.0 → 2.1.1
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.
- package/README.md +305 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +77 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/chat.d.ts +3 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +62 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/chatThinking.d.ts +3 -0
- package/dist/commands/chatThinking.d.ts.map +1 -0
- package/dist/commands/chatThinking.js +59 -0
- package/dist/commands/chatThinking.js.map +1 -0
- package/dist/commands/classifyIab.d.ts +3 -0
- package/dist/commands/classifyIab.d.ts.map +1 -0
- package/dist/commands/classifyIab.js +58 -0
- package/dist/commands/classifyIab.js.map +1 -0
- package/dist/commands/classifyIabEnriched.d.ts.map +1 -1
- package/dist/commands/classifyIabEnriched.js +2 -2
- package/dist/commands/classifyIabEnriched.js.map +1 -1
- package/dist/commands/classifyStructured.d.ts +3 -0
- package/dist/commands/classifyStructured.d.ts.map +1 -0
- package/dist/commands/classifyStructured.js +73 -0
- package/dist/commands/classifyStructured.js.map +1 -0
- package/dist/commands/classifyZeroShot.d.ts +3 -0
- package/dist/commands/classifyZeroShot.d.ts.map +1 -0
- package/dist/commands/classifyZeroShot.js +75 -0
- package/dist/commands/classifyZeroShot.js.map +1 -0
- package/dist/commands/extractEntities.d.ts +3 -0
- package/dist/commands/extractEntities.d.ts.map +1 -0
- package/dist/commands/extractEntities.js +85 -0
- package/dist/commands/extractEntities.js.map +1 -0
- package/dist/commands/extractJson.d.ts +3 -0
- package/dist/commands/extractJson.d.ts.map +1 -0
- package/dist/commands/extractJson.js +72 -0
- package/dist/commands/extractJson.js.map +1 -0
- package/dist/commands/extractPii.d.ts +3 -0
- package/dist/commands/extractPii.d.ts.map +1 -0
- package/dist/commands/extractPii.js +77 -0
- package/dist/commands/extractPii.js.map +1 -0
- package/dist/commands/generateFollowups.d.ts +3 -0
- package/dist/commands/generateFollowups.d.ts.map +1 -0
- package/dist/commands/generateFollowups.js +58 -0
- package/dist/commands/generateFollowups.js.map +1 -0
- package/dist/commands/redactPii.d.ts +3 -0
- package/dist/commands/redactPii.d.ts.map +1 -0
- package/dist/commands/redactPii.js +62 -0
- package/dist/commands/redactPii.js.map +1 -0
- package/dist/commands/summarize.d.ts +3 -0
- package/dist/commands/summarize.d.ts.map +1 -0
- package/dist/commands/summarize.js +58 -0
- package/dist/commands/summarize.js.map +1 -0
- package/dist/lib/responses.d.ts +10 -0
- package/dist/lib/responses.d.ts.map +1 -0
- package/dist/lib/responses.js +2 -0
- package/dist/lib/responses.js.map +1 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,22 +1,321 @@
|
|
|
1
1
|
# zerogpu-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/zerogpu-cli)
|
|
4
|
+
[](https://nodejs.org)
|
|
5
|
+
[](./LICENSE)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
The official command-line interface for [ZeroGPU](https://zerogpu.ai) — run fast, edge-optimized inference models (classification, extraction, redaction, chat, summarization) right from your terminal.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [Authentication](#authentication)
|
|
16
|
+
- [Commands](#commands)
|
|
17
|
+
- [Account](#account)
|
|
18
|
+
- [`login`](#login)
|
|
19
|
+
- [`status`](#status)
|
|
20
|
+
- [Chat & Generation](#chat--generation)
|
|
21
|
+
- [`chat`](#chat)
|
|
22
|
+
- [`chat_thinking`](#chat_thinking)
|
|
23
|
+
- [`summarize`](#summarize)
|
|
24
|
+
- [`generate_followups`](#generate_followups)
|
|
25
|
+
- [Classification](#classification)
|
|
26
|
+
- [`classify_iab`](#classify_iab)
|
|
27
|
+
- [`classify_iab_enriched`](#classify_iab_enriched)
|
|
28
|
+
- [`classify_structured`](#classify_structured)
|
|
29
|
+
- [`classify_zero_shot`](#classify_zero_shot)
|
|
30
|
+
- [Extraction](#extraction)
|
|
31
|
+
- [`extract_entities`](#extract_entities)
|
|
32
|
+
- [`extract_json`](#extract_json)
|
|
33
|
+
- [`extract_pii`](#extract_pii)
|
|
34
|
+
- [`redact_pii`](#redact_pii)
|
|
35
|
+
- [Environment Variables](#environment-variables)
|
|
36
|
+
- [Output](#output)
|
|
37
|
+
- [Troubleshooting](#troubleshooting)
|
|
38
|
+
- [Contributing](#contributing)
|
|
39
|
+
- [License](#license)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
6
44
|
|
|
7
45
|
```bash
|
|
8
|
-
npm install -g zerogpu-cli
|
|
46
|
+
npm install -g zerogpu-cli@latest
|
|
9
47
|
```
|
|
10
48
|
|
|
11
|
-
Requires Node.js 20
|
|
49
|
+
Requires **Node.js 20+**.
|
|
12
50
|
|
|
13
|
-
|
|
51
|
+
Verify the install:
|
|
14
52
|
|
|
15
53
|
```bash
|
|
16
54
|
zerogpu --version
|
|
17
55
|
zerogpu --help
|
|
18
56
|
```
|
|
19
57
|
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# 1. Sign in (you'll be prompted for your API key and project ID)
|
|
64
|
+
zerogpu login
|
|
65
|
+
|
|
66
|
+
# 2. Check your session
|
|
67
|
+
zerogpu status
|
|
68
|
+
|
|
69
|
+
# 3. Run your first command
|
|
70
|
+
zerogpu summarize "ZeroGPU runs small, fast models at the edge so you can ship AI features without managing GPUs."
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Authentication
|
|
76
|
+
|
|
77
|
+
Every inference command requires a valid API key **and** a project ID. You can provide them in two ways:
|
|
78
|
+
|
|
79
|
+
1. **`zerogpu login`** — stores credentials in a local config file and exports `ZEROGPU_API_KEY` to your shell profile.
|
|
80
|
+
2. **Environment variable** — set `ZEROGPU_API_KEY` directly (useful for CI). The project ID still needs to be saved via `login` or supplied through the config file.
|
|
81
|
+
|
|
82
|
+
Get your API key (`zgpu-api-…`) and project ID (UUID) from the [ZeroGPU dashboard](https://zerogpu.ai).
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Commands
|
|
87
|
+
|
|
88
|
+
All commands follow the pattern:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
zerogpu <command> [arguments] [options]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Run `zerogpu <command> --help` for command-level help.
|
|
95
|
+
|
|
96
|
+
### Account
|
|
97
|
+
|
|
98
|
+
#### `login`
|
|
99
|
+
|
|
100
|
+
Sign in to ZeroGPU. Prompts for your API key (masked input) and project ID, validates them, and persists the credentials.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
zerogpu login
|
|
104
|
+
zerogpu login --api-key zgpu-api-xxxxxxxx --project-id 4ed3e5bb-c2ed-4d4a-8a66-2b161a27fd1a
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Option | Description |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `--api-key <key>` | Provide the API key directly (skips the prompt). |
|
|
110
|
+
| `--project-id <id>` | Provide the project ID directly (skips the prompt). |
|
|
111
|
+
|
|
112
|
+
#### `status`
|
|
113
|
+
|
|
114
|
+
Check whether you're signed in and where the API key was loaded from.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
zerogpu status
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### Chat & Generation
|
|
123
|
+
|
|
124
|
+
#### `chat`
|
|
125
|
+
|
|
126
|
+
Chat with the **LFM2.5-1.2B-Instruct** model.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
zerogpu chat "Explain edge inference in one sentence."
|
|
130
|
+
zerogpu chat "Translate to French: Good morning." -i "You are a precise translator."
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
| Option | Description |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `-i, --instructions <text>` | System instructions that steer the assistant's behavior. |
|
|
136
|
+
|
|
137
|
+
#### `chat_thinking`
|
|
138
|
+
|
|
139
|
+
Chat with the **LFM2.5-1.2B-Thinking** model, which returns reasoning alongside its answer.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
zerogpu chat_thinking "If a train leaves at 3pm at 60mph, when does it arrive 180 miles later?"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `summarize`
|
|
146
|
+
|
|
147
|
+
Summarize text with the **t5-small** model.
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
zerogpu summarize "Long article text goes here..."
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### `generate_followups`
|
|
154
|
+
|
|
155
|
+
Generate contextual follow-up questions using the ZeroGPU follow-up edge model.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
zerogpu generate_followups "We just shipped a new pricing page focused on enterprise plans."
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Classification
|
|
164
|
+
|
|
165
|
+
#### `classify_iab`
|
|
166
|
+
|
|
167
|
+
Classify text against the **IAB** audience and content taxonomy using the ZeroGPU IAB edge model.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
zerogpu classify_iab "Tips for first-time homebuyers in 2026."
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### `classify_iab_enriched`
|
|
174
|
+
|
|
175
|
+
Same as `classify_iab` but returns enriched output: audience, topics, keywords, and intent.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
zerogpu classify_iab_enriched "Best running shoes for marathon training."
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### `classify_structured`
|
|
182
|
+
|
|
183
|
+
Classify text against a **structured schema** of categories and allowed labels using GLiNER2.
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
zerogpu classify_structured "The product arrived broken and I want a refund." \
|
|
187
|
+
--schema '{"sentiment":["positive","negative","neutral"],"intent":["complaint","praise","question"]}'
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| Option | Description |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `-s, --schema <json>` | **Required.** JSON object mapping category name → allowed labels. |
|
|
193
|
+
|
|
194
|
+
#### `classify_zero_shot`
|
|
195
|
+
|
|
196
|
+
Zero-shot classification against arbitrary candidate labels using **DeBERTa v3**.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Repeat --label for each candidate
|
|
200
|
+
zerogpu classify_zero_shot "The stock market dropped 3% today." \
|
|
201
|
+
--label finance --label sports --label politics
|
|
202
|
+
|
|
203
|
+
# Or pass them as a comma-separated list
|
|
204
|
+
zerogpu classify_zero_shot "The stock market dropped 3% today." \
|
|
205
|
+
--labels finance,sports,politics
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
| Option | Description |
|
|
209
|
+
|---|---|
|
|
210
|
+
| `-l, --label <label>` | Candidate label (repeatable). |
|
|
211
|
+
| `--labels <a,b,c>` | Comma-separated list of candidate labels. |
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### Extraction
|
|
216
|
+
|
|
217
|
+
#### `extract_entities`
|
|
218
|
+
|
|
219
|
+
Extract named entities from text using **GLiNER2** with custom labels.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
zerogpu extract_entities "Tim Cook visited the Cupertino campus on Tuesday." \
|
|
223
|
+
--label person --label organization --label location --threshold 0.4
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
| Option | Default | Description |
|
|
227
|
+
|---|---|---|
|
|
228
|
+
| `-l, --label <label>` | — | Entity label to extract (repeatable). |
|
|
229
|
+
| `--labels <a,b,c>` | — | Comma-separated entity labels. |
|
|
230
|
+
| `-t, --threshold <number>` | `0.3` | Confidence threshold between 0 and 1. |
|
|
231
|
+
|
|
232
|
+
#### `extract_json`
|
|
233
|
+
|
|
234
|
+
Extract **structured JSON** from text against a provided schema using GLiNER2.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
zerogpu extract_json "Email Jane Doe at jane@example.com or call 555-0100." \
|
|
238
|
+
--schema '{"contact":["name::str::Full name","email::str::Email address","phone::str::Phone number"]}'
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
| Option | Description |
|
|
242
|
+
|---|---|
|
|
243
|
+
| `-s, --schema <json>` | **Required.** Schema as a JSON string. Field format: `name::type::description`. |
|
|
244
|
+
|
|
245
|
+
#### `extract_pii`
|
|
246
|
+
|
|
247
|
+
Extract PII entities (persons, emails, phone numbers, etc.) using `gliner-multi-pii-v1`.
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
zerogpu extract_pii "Contact John Smith at john@acme.com or +1-415-555-0100." \
|
|
251
|
+
--threshold 0.5 --categories identity,contact
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
| Option | Default | Description |
|
|
255
|
+
|---|---|---|
|
|
256
|
+
| `-t, --threshold <number>` | `0.5` | Confidence threshold. |
|
|
257
|
+
| `-c, --categories <list>` | `identity,contact` | Comma-separated PII categories. |
|
|
258
|
+
|
|
259
|
+
#### `redact_pii`
|
|
260
|
+
|
|
261
|
+
Detect and **redact** PII in text — returns the input with sensitive spans masked by label.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
zerogpu redact_pii "Call Sarah at 415-555-0100 or email sarah@acme.com."
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Environment Variables
|
|
270
|
+
|
|
271
|
+
| Variable | Purpose |
|
|
272
|
+
|---|---|
|
|
273
|
+
| `ZEROGPU_API_KEY` | Overrides the API key from the config file. Set automatically by `zerogpu login` for your default shell. |
|
|
274
|
+
|
|
275
|
+
The project ID is read from the saved config file written during `zerogpu login`.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Output
|
|
280
|
+
|
|
281
|
+
- Inference commands print the model's response to **stdout**. When the response is valid JSON, it is pretty-printed.
|
|
282
|
+
- Errors and diagnostic messages are written to **stderr**.
|
|
283
|
+
- All commands exit with code **`0`** on success and **`1`** on failure — safe to use in pipelines and scripts.
|
|
284
|
+
|
|
285
|
+
Example:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
zerogpu classify_iab "Tips for first-time homebuyers." > result.json
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Troubleshooting
|
|
294
|
+
|
|
295
|
+
- **`You're not fully signed in yet.`** Run `zerogpu login` again, or check `zerogpu status`.
|
|
296
|
+
- **`That doesn't look like a valid API key`** Keys must start with `zgpu-api-`.
|
|
297
|
+
- **`That doesn't look like a valid project ID`** Project IDs must be a UUID (e.g. `4ed3e5bb-c2ed-4d4a-8a66-2b161a27fd1a`).
|
|
298
|
+
- **`ZEROGPU_API_KEY` not picked up in a new shell:** open a new terminal, or `source` your shell config file (the `login` command prints the path).
|
|
299
|
+
- **HTTP errors** are surfaced with the response status and body — inspect them to debug request issues.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Contributing
|
|
304
|
+
|
|
305
|
+
Issues and pull requests are welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) and our [Code of Conduct](./CODE_OF_CONDUCT.md).
|
|
306
|
+
|
|
307
|
+
Security concerns? See [SECURITY.md](./SECURITY.md).
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
git clone https://github.com/zerogpu/cli.git
|
|
311
|
+
cd cli
|
|
312
|
+
npm install
|
|
313
|
+
npm run build
|
|
314
|
+
npm test
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
20
319
|
## License
|
|
21
320
|
|
|
22
|
-
[MIT](./LICENSE)
|
|
321
|
+
Released under the [MIT License](./LICENSE).
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiFpC,wBAAgB,YAAY,IAAI,OAAO,CAwBtC;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAIxC"}
|
package/dist/cli.js
CHANGED
|
@@ -2,11 +2,75 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
+
import updateNotifier from "update-notifier";
|
|
6
|
+
import { registerChatCommand } from "./commands/chat.js";
|
|
7
|
+
import { registerChatThinkingCommand } from "./commands/chatThinking.js";
|
|
8
|
+
import { registerClassifyIabCommand } from "./commands/classifyIab.js";
|
|
5
9
|
import { registerClassifyIabEnrichedCommand } from "./commands/classifyIabEnriched.js";
|
|
10
|
+
import { registerClassifyStructuredCommand } from "./commands/classifyStructured.js";
|
|
11
|
+
import { registerClassifyZeroShotCommand } from "./commands/classifyZeroShot.js";
|
|
12
|
+
import { registerExtractEntitiesCommand } from "./commands/extractEntities.js";
|
|
13
|
+
import { registerExtractJsonCommand } from "./commands/extractJson.js";
|
|
14
|
+
import { registerExtractPiiCommand } from "./commands/extractPii.js";
|
|
15
|
+
import { registerGenerateFollowupsCommand } from "./commands/generateFollowups.js";
|
|
6
16
|
import { registerLoginCommand } from "./commands/login.js";
|
|
17
|
+
import { registerRedactPiiCommand } from "./commands/redactPii.js";
|
|
7
18
|
import { registerStatusCommand } from "./commands/status.js";
|
|
19
|
+
import { registerSummarizeCommand } from "./commands/summarize.js";
|
|
8
20
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
21
|
const pkg = JSON.parse(readFileSync(resolve(__dirname, "..", "package.json"), "utf8"));
|
|
22
|
+
const MIN_SUPPORTED_VERSION = "2.0.0";
|
|
23
|
+
function parseVersion(v) {
|
|
24
|
+
const parts = (v.split("-")[0] ?? "0.0.0")
|
|
25
|
+
.split(".")
|
|
26
|
+
.map((n) => Number.parseInt(n, 10) || 0);
|
|
27
|
+
return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
|
|
28
|
+
}
|
|
29
|
+
function isVersionBelow(current, minimum) {
|
|
30
|
+
const [ca, cb, cc] = parseVersion(current);
|
|
31
|
+
const [ma, mb, mc] = parseVersion(minimum);
|
|
32
|
+
if (ca !== ma)
|
|
33
|
+
return ca < ma;
|
|
34
|
+
if (cb !== mb)
|
|
35
|
+
return cb < mb;
|
|
36
|
+
return cc < mc;
|
|
37
|
+
}
|
|
38
|
+
function warnIfBelowMinimum() {
|
|
39
|
+
if (isVersionBelow(pkg.version, MIN_SUPPORTED_VERSION)) {
|
|
40
|
+
process.stderr.write(`\x1b[33m⚠️ zerogpu-cli ${pkg.version} is below the minimum supported version (${MIN_SUPPORTED_VERSION}).\x1b[0m\n` +
|
|
41
|
+
`Some features may not work correctly. Please update:\n` +
|
|
42
|
+
` npm i -g zerogpu-cli@latest\n\n`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function notifyUpdate() {
|
|
46
|
+
const notifier = updateNotifier({
|
|
47
|
+
pkg,
|
|
48
|
+
updateCheckInterval: 1000 * 60 * 60 * 24,
|
|
49
|
+
});
|
|
50
|
+
const update = notifier.update;
|
|
51
|
+
if (!update)
|
|
52
|
+
return;
|
|
53
|
+
if (update.type === "major") {
|
|
54
|
+
notifier.notify({
|
|
55
|
+
defer: false,
|
|
56
|
+
isGlobal: true,
|
|
57
|
+
message: "⚠️ BREAKING update available: {currentVersion} → {latestVersion}\n" +
|
|
58
|
+
"This is a major release and may include breaking changes.\n" +
|
|
59
|
+
"Update now: {updateCommand}",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else if (update.type === "minor") {
|
|
63
|
+
notifier.notify({
|
|
64
|
+
defer: false,
|
|
65
|
+
isGlobal: true,
|
|
66
|
+
message: "New features available: {currentVersion} → {latestVersion}\n" +
|
|
67
|
+
"Please update: {updateCommand}",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
process.stderr.write(`\x1b[2m(zerogpu-cli ${update.latest} available — run \`npm i -g zerogpu-cli@latest\` to update)\x1b[0m\n`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
10
74
|
export function buildProgram() {
|
|
11
75
|
const program = new Command();
|
|
12
76
|
program
|
|
@@ -15,10 +79,23 @@ export function buildProgram() {
|
|
|
15
79
|
.version(pkg.version, "-v, --version", "Output the current version.");
|
|
16
80
|
registerLoginCommand(program);
|
|
17
81
|
registerStatusCommand(program);
|
|
82
|
+
registerClassifyIabCommand(program);
|
|
18
83
|
registerClassifyIabEnrichedCommand(program);
|
|
84
|
+
registerClassifyStructuredCommand(program);
|
|
85
|
+
registerClassifyZeroShotCommand(program);
|
|
86
|
+
registerGenerateFollowupsCommand(program);
|
|
87
|
+
registerRedactPiiCommand(program);
|
|
88
|
+
registerExtractPiiCommand(program);
|
|
89
|
+
registerExtractEntitiesCommand(program);
|
|
90
|
+
registerExtractJsonCommand(program);
|
|
91
|
+
registerSummarizeCommand(program);
|
|
92
|
+
registerChatCommand(program);
|
|
93
|
+
registerChatThinkingCommand(program);
|
|
19
94
|
return program;
|
|
20
95
|
}
|
|
21
96
|
export function run(argv) {
|
|
97
|
+
warnIfBelowMinimum();
|
|
98
|
+
notifyUpdate();
|
|
22
99
|
buildProgram().parse(argv);
|
|
23
100
|
}
|
|
24
101
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2B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@
|
|
|
1
|
+
import { getApiKey, getProjectId } from "../lib/auth.js";
|
|
2
|
+
import { RESPONSES_ENDPOINT, } from "../lib/responses.js";
|
|
3
|
+
const MODEL = "LFM2.5-1.2B-Instruct";
|
|
4
|
+
export function registerChatCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("chat <text>")
|
|
7
|
+
.description("Chat with the LFM2.5 instruct model.")
|
|
8
|
+
.option("-i, --instructions <instructions>", "System instructions that steer the assistant's behavior.")
|
|
9
|
+
.action(async (text, opts) => {
|
|
10
|
+
const apiKey = getApiKey();
|
|
11
|
+
const projectId = getProjectId();
|
|
12
|
+
if (!apiKey || !projectId) {
|
|
13
|
+
console.error("You're not fully signed in yet. Run 'zerogpu login' to set your API key and project ID.");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const body = {
|
|
17
|
+
model: MODEL,
|
|
18
|
+
input: text,
|
|
19
|
+
};
|
|
20
|
+
if (opts.instructions)
|
|
21
|
+
body.instructions = opts.instructions;
|
|
22
|
+
let response;
|
|
23
|
+
try {
|
|
24
|
+
response = await fetch(RESPONSES_ENDPOINT, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
"content-type": "application/json",
|
|
28
|
+
"x-api-key": apiKey.apiKey,
|
|
29
|
+
"x-project-id": projectId.projectId,
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify(body),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
36
|
+
console.error(`Request failed: ${message}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
const errBody = await response.text();
|
|
41
|
+
console.error(`Request failed with status ${response.status}.`);
|
|
42
|
+
if (errBody)
|
|
43
|
+
console.error(errBody);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const data = (await response.json());
|
|
47
|
+
const content = data.output?.[0]?.content?.find((c) => c.type === "output_text")?.text ?? data.output?.[0]?.content?.[0]?.text;
|
|
48
|
+
if (!content) {
|
|
49
|
+
console.error("Response did not contain any chat content.");
|
|
50
|
+
console.error(JSON.stringify(data, null, 2));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const parsed = JSON.parse(content);
|
|
55
|
+
console.log(JSON.stringify(parsed, null, 2));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
console.log(content);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACL,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,KAAK,GAAG,sBAAsB,CAAC;AAErC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,sCAAsC,CAAC;SACnD,MAAM,CACL,mCAAmC,EACnC,0DAA0D,CAC3D;SACA,MAAM,CACL,KAAK,EAAE,IAAY,EAAE,IAA+B,EAAE,EAAE;QACtD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QAEjC,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CACX,yFAAyF,CAC1F,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,GAA4B;YACpC,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,IAAI,IAAI,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E,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QAChD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC5D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CACF,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatThinking.d.ts","sourceRoot":"","sources":["../../src/commands/chatThinking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6DlE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getApiKey, getProjectId } from "../lib/auth.js";
|
|
2
|
+
import { RESPONSES_ENDPOINT, } from "../lib/responses.js";
|
|
3
|
+
const MODEL = "LFM2.5-1.2B-Thinking";
|
|
4
|
+
export function registerChatThinkingCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("chat_thinking <text>")
|
|
7
|
+
.description("Chat with the LFM2.5 Thinking model, which returns reasoning alongside its answer.")
|
|
8
|
+
.action(async (text) => {
|
|
9
|
+
const apiKey = getApiKey();
|
|
10
|
+
const projectId = getProjectId();
|
|
11
|
+
if (!apiKey || !projectId) {
|
|
12
|
+
console.error("You're not fully signed in yet. Run 'zerogpu login' to set your API key and project ID.");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
let response;
|
|
16
|
+
try {
|
|
17
|
+
response = await fetch(RESPONSES_ENDPOINT, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
"content-type": "application/json",
|
|
21
|
+
"x-api-key": apiKey.apiKey,
|
|
22
|
+
"x-project-id": projectId.projectId,
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
model: MODEL,
|
|
26
|
+
input: text,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
32
|
+
console.error(`Request failed: ${message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const body = await response.text();
|
|
37
|
+
console.error(`Request failed with status ${response.status}.`);
|
|
38
|
+
if (body)
|
|
39
|
+
console.error(body);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
const data = (await response.json());
|
|
43
|
+
const content = data.output?.[0]?.content?.find((c) => c.type === "output_text")
|
|
44
|
+
?.text ?? data.output?.[0]?.content?.[0]?.text;
|
|
45
|
+
if (!content) {
|
|
46
|
+
console.error("Response did not contain any chat content.");
|
|
47
|
+
console.error(JSON.stringify(data, null, 2));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(content);
|
|
52
|
+
console.log(JSON.stringify(parsed, null, 2));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
console.log(content);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=chatThinking.js.map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AAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifyIab.d.ts","sourceRoot":"","sources":["../../src/commands/classifyIab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6DjE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getApiKey, getProjectId } from "../lib/auth.js";
|
|
2
|
+
import { RESPONSES_ENDPOINT, } from "../lib/responses.js";
|
|
3
|
+
const MODEL = "zlm-v1-iab-classify-edge";
|
|
4
|
+
export function registerClassifyIabCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("classify_iab <text>")
|
|
7
|
+
.description("Classify text with the IAB edge model (audience and content taxonomy).")
|
|
8
|
+
.action(async (text) => {
|
|
9
|
+
const apiKey = getApiKey();
|
|
10
|
+
const projectId = getProjectId();
|
|
11
|
+
if (!apiKey || !projectId) {
|
|
12
|
+
console.error("You're not fully signed in yet. Run 'zerogpu login' to set your API key and project ID.");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
let response;
|
|
16
|
+
try {
|
|
17
|
+
response = await fetch(RESPONSES_ENDPOINT, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
"content-type": "application/json",
|
|
21
|
+
"x-api-key": apiKey.apiKey,
|
|
22
|
+
"x-project-id": projectId.projectId,
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
model: MODEL,
|
|
26
|
+
input: text,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
32
|
+
console.error(`Request failed: ${message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const body = await response.text();
|
|
37
|
+
console.error(`Request failed with status ${response.status}.`);
|
|
38
|
+
if (body)
|
|
39
|
+
console.error(body);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
const data = (await response.json());
|
|
43
|
+
const content = data.output?.[0]?.content?.find((c) => c.type === "output_text")?.text ?? data.output?.[0]?.content?.[0]?.text;
|
|
44
|
+
if (!content) {
|
|
45
|
+
console.error("Response did not contain any classification content.");
|
|
46
|
+
console.error(JSON.stringify(data, null, 2));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(content);
|
|
51
|
+
console.log(JSON.stringify(parsed, null, 2));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
console.log(content);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=classifyIab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifyIab.js","sourceRoot":"","sources":["../../src/commands/classifyIab.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACL,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,KAAK,GAAG,0BAA0B,CAAC;AAEzC,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IACzD,OAAO;SACJ,OAAO,CAAC,qBAAqB,CAAC;SAC9B,WAAW,CACV,wEAAwE,CACzE;SACA,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QAEjC,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,CAAC,KA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,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAChC,EAAE,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QAChD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACtE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifyIabEnriched.d.ts","sourceRoot":"","sources":["../../src/commands/classifyIabEnriched.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"classifyIabEnriched.d.ts","sourceRoot":"","sources":["../../src/commands/classifyIabEnriched.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6DzE"}
|