pplx-zero 1.1.8 → 2.1.0
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/LICENSE +1 -1
- package/README.md +84 -497
- package/bin/pplx.js +28 -0
- package/package.json +28 -62
- package/src/api.test.ts +21 -0
- package/src/api.ts +116 -0
- package/src/env.ts +37 -0
- package/src/files.test.ts +71 -0
- package/src/files.ts +44 -0
- package/src/history.test.ts +84 -0
- package/src/history.ts +86 -0
- package/src/index.ts +179 -0
- package/src/output.test.ts +41 -0
- package/src/output.ts +35 -0
- package/dist/index.js +0 -10532
package/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,546 +1,133 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pplx-zero
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/pplx-zero)
|
|
4
|
+
[](https://aur.archlinux.org/packages/pplx-zero)
|
|
5
|
+

|
|
6
|
+

|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## ✨ What Makes PPLX‑Zero Special
|
|
10
|
-
|
|
11
|
-
- **⚡ Blazing Fast**: Get answers in under a second with optimized API calls
|
|
12
|
-
- **🧠 Smart Models**: Choose from Sonar, Sonar‑Pro, Sonar‑Reasoning, and Deep‑Research models
|
|
13
|
-
- **📎 Multimodal**: Analyze documents, images, and combinations seamlessly
|
|
14
|
-
- **🔄 Auto‑Update**: Stay current with simplified update management
|
|
15
|
-
- **⚙️ Developer‑First**: Built for CI/CD, agent pipelines, and programmatic use
|
|
16
|
-
- **🎯 Minimal Setup**: One environment variable and you're ready to go
|
|
17
|
-
|
|
18
|
-
## 📦 Installation
|
|
19
|
-
|
|
20
|
-
Choose the installation method that works best for you:
|
|
21
|
-
|
|
22
|
-
### 🚀 Quick Install (Recommended)
|
|
8
|
+
Search the web with AI from your terminal. Zero bloat, maximum speed.
|
|
23
9
|
|
|
24
10
|
```bash
|
|
25
|
-
|
|
26
|
-
npm install -g pplx-zero
|
|
27
|
-
# or
|
|
28
|
-
bun install -g pplx-zero
|
|
29
|
-
|
|
30
|
-
# Verify installation
|
|
31
|
-
pplx --version
|
|
11
|
+
pplx "what is bun"
|
|
32
12
|
```
|
|
33
13
|
|
|
34
|
-
|
|
14
|
+
## Why pplx-zero?
|
|
35
15
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
sudo mv pplx-v1.1.7-linux-x64 /usr/local/bin/pplx
|
|
42
|
-
|
|
43
|
-
# Linux (ARM64) - Raspberry Pi, ARM servers
|
|
44
|
-
wget https://github.com/codewithkenzo/pplx-zero/releases/latest/download/pplx-v1.1.7-linux-arm64
|
|
45
|
-
chmod +x pplx-v1.1.7-linux-arm64
|
|
46
|
-
sudo mv pplx-v1.1.7-linux-arm64 /usr/local/bin/pplx
|
|
47
|
-
|
|
48
|
-
# macOS (Intel) - Macs with Intel processors
|
|
49
|
-
wget https://github.com/codewithkenzo/pplx-zero/releases/latest/download/pplx-v1.1.7-darwin-x64
|
|
50
|
-
chmod +x pplx-v1.1.7-darwin-x64
|
|
51
|
-
sudo mv pplx-v1.1.7-darwin-x64 /usr/local/bin/pplx
|
|
52
|
-
|
|
53
|
-
# macOS (Apple Silicon) - Macs with M1/M2/M3 chips
|
|
54
|
-
wget https://github.com/codewithkenzo/pplx-zero/releases/latest/download/pplx-v1.1.7-darwin-arm64
|
|
55
|
-
chmod +x pplx-v1.1.7-darwin-arm64
|
|
56
|
-
sudo mv pplx-v1.1.7-darwin-arm64 /usr/local/bin/pplx
|
|
57
|
-
|
|
58
|
-
# Windows (x64) - Most Windows computers
|
|
59
|
-
# Download pplx-v1.1.7-windows-x64.exe from GitHub releases
|
|
60
|
-
# Add to your PATH or run directly
|
|
61
|
-
```
|
|
16
|
+
- **Fast** — Bun-native, streams responses as they arrive
|
|
17
|
+
- **Minimal** — ~400 lines of code, one dependency (zod)
|
|
18
|
+
- **Powerful** — 5 models including deep research, file & image support
|
|
19
|
+
- **Conversational** — Continue previous queries with `-c`
|
|
20
|
+
- **Unix-friendly** — Pipes, JSON output, history, exit codes done right
|
|
62
21
|
|
|
63
|
-
|
|
22
|
+
## Installation
|
|
64
23
|
|
|
65
24
|
```bash
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
chmod +x pplx
|
|
69
|
-
sudo mv pplx /usr/local/bin/pplx
|
|
70
|
-
```
|
|
25
|
+
# Bun (recommended)
|
|
26
|
+
bun install -g pplx-zero
|
|
71
27
|
|
|
72
|
-
|
|
28
|
+
# npm (requires bun installed)
|
|
29
|
+
npm install -g pplx-zero
|
|
73
30
|
|
|
74
|
-
|
|
75
|
-
# Using yay (recommended)
|
|
31
|
+
# Arch Linux
|
|
76
32
|
yay -S pplx-zero
|
|
77
|
-
|
|
78
|
-
# Using paru
|
|
79
|
-
paru -S pplx-zero
|
|
80
|
-
|
|
81
|
-
# Verify installation
|
|
82
|
-
pplx --version
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### 🔧 Build from Source
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# 1) Clone the repository
|
|
89
|
-
git clone https://github.com/codewithkenzo/pplx-zero.git
|
|
90
|
-
cd pplx-zero
|
|
91
|
-
|
|
92
|
-
# 2) Install dependencies and build
|
|
93
|
-
bun install && bun run build
|
|
94
|
-
|
|
95
|
-
# 3) Link the CLI (system-wide)
|
|
96
|
-
sudo ln -s "$(pwd)/dist/index.js" /usr/local/bin/pplx
|
|
97
|
-
|
|
98
|
-
# 4) Verify installation
|
|
99
|
-
pplx --version
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## ⚙️ Configuration
|
|
105
|
-
|
|
106
|
-
### API Key Setup
|
|
107
|
-
|
|
108
|
-
Set your Perplexity API key as an environment variable:
|
|
109
|
-
|
|
110
|
-
**Linux/macOS:**
|
|
111
|
-
```bash
|
|
112
|
-
# Temporary (current session)
|
|
113
|
-
export PERPLEXITY_API_KEY="your-api-key"
|
|
114
|
-
|
|
115
|
-
# Permanent (add to ~/.bashrc, ~/.zshrc, etc.)
|
|
116
|
-
echo 'export PERPLEXITY_API_KEY="your-api-key"' >> ~/.bashrc
|
|
117
|
-
source ~/.bashrc
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**Windows (PowerShell):**
|
|
121
|
-
```powershell
|
|
122
|
-
# Temporary (current session)
|
|
123
|
-
$env:PERPLEXITY_API_KEY = "your-api-key"
|
|
124
|
-
|
|
125
|
-
# Permanent
|
|
126
|
-
[Environment]::SetEnvironmentVariable("PERPLEXITY_API_KEY", "your-api-key", "User")
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**Windows (CMD):**
|
|
130
|
-
```cmd
|
|
131
|
-
# Permanent
|
|
132
|
-
setx PERPLEXITY_API_KEY "your-api-key"
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
> 🔑 **Get your API key** from your [Perplexity account settings](https://www.perplexity.ai/settings/api) and keep it secure. Never share your API key or commit it to version control.
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
## 🔄 Auto‑Update Management
|
|
140
|
-
|
|
141
|
-
PPLX‑Zero includes a simplified auto‑update system that keeps you current with the latest features and security updates.
|
|
142
|
-
|
|
143
|
-
### Basic Update Commands
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# Check for available updates
|
|
147
|
-
pplx update --check
|
|
148
|
-
|
|
149
|
-
# Install updates and relaunch automatically
|
|
150
|
-
pplx update --auto
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Update Workflow
|
|
154
|
-
|
|
155
|
-
1. **Automatic Notifications**: PPLX‑Zero checks for updates once per day and notifies you when a new version is available
|
|
156
|
-
2. **Smart Installation**: The updater detects your installation method (npm, AUR, binary) and uses the appropriate update mechanism
|
|
157
|
-
3. **Seamless Relaunch**: When using `--auto`, PPLX‑Zero installs the update and relaunches with your original command
|
|
158
|
-
|
|
159
|
-
### Advanced Update Options
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
# Force update check (ignores cache)
|
|
163
|
-
pplx update --check
|
|
164
|
-
|
|
165
|
-
# Update during automation without interaction
|
|
166
|
-
pplx update --auto --quiet
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Troubleshooting Updates
|
|
170
|
-
|
|
171
|
-
| Issue | Solution |
|
|
172
|
-
|-------|----------|
|
|
173
|
-
| **Permission denied** | Run with `sudo` or check installation directory permissions |
|
|
174
|
-
| **Network timeout** | Check internet connection and try again |
|
|
175
|
-
| **Update fails** | Manually install using your original installation method |
|
|
176
|
-
| **Lock file error** | Wait for current update to complete or manually remove `~/.pplx-zero/.updating.lock` |
|
|
177
|
-
|
|
178
|
-
The auto‑update system respects your system configuration and won't modify files without proper permissions.
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## 🚀 Quick Examples
|
|
183
|
-
|
|
184
|
-
### Basic Search
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
# Simple search (default model: sonar)
|
|
188
|
-
pplx "python type hints best practices"
|
|
189
|
-
|
|
190
|
-
# Multiple queries in one command
|
|
191
|
-
pplx "React hooks tutorial" "TypeScript generics" "Docker best practices"
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Advanced Models
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
# Research with Sonar Pro (more detailed analysis)
|
|
198
|
-
pplx -m sonar-pro "React 19 Hooks new features"
|
|
199
|
-
|
|
200
|
-
# Deep research with comprehensive web context
|
|
201
|
-
pplx -m sonar-deep-research "best Rust web frameworks 2025"
|
|
202
|
-
|
|
203
|
-
# Mathematical reasoning and proofs
|
|
204
|
-
pplx -m sonar-reasoning "prove this algorithm runs in O(n log n)"
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Document & Image Analysis
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
# Summarize a PDF report quickly
|
|
211
|
-
pplx -f report.pdf "summarize key findings and risks"
|
|
212
|
-
|
|
213
|
-
# Understand an interface from a screenshot
|
|
214
|
-
pplx -i screenshot.png "what is this UI and what are the next steps?"
|
|
215
|
-
|
|
216
|
-
# Combine multiple files in one analysis
|
|
217
|
-
pplx -f data.csv -i chart.png "spot anomalies and explain the chart"
|
|
218
|
-
|
|
219
|
-
# Multiple file attachments
|
|
220
|
-
pplx -f report.pdf --attach data.csv --attach summary.md "analyze all documents"
|
|
221
|
-
|
|
222
|
-
# Multiple documents of same type using --attach
|
|
223
|
-
pplx --attach doc1.pdf --attach doc2.pdf --attach doc3.txt "compare all reports"
|
|
224
|
-
|
|
225
|
-
# Multiple images using --attach-image
|
|
226
|
-
pplx --attach-image screenshot1.png --attach-image screenshot2.png "analyze the UI flow"
|
|
227
|
-
|
|
228
|
-
# Mixed multiple files (documents + images)
|
|
229
|
-
pplx -f main.pdf --attach appendix.md --attach-image chart.png --attach-image diagram.jpg "comprehensive analysis"
|
|
230
|
-
|
|
231
|
-
# Multiple files with positional arguments (all treated as files)
|
|
232
|
-
pplx file1.pdf file2.txt file3.md "what's in these files"
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Batch Processing
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
# Stream newline-delimited JSON for agents or UNIX pipes
|
|
239
|
-
pplx -o jsonl "AI trends"
|
|
240
|
-
|
|
241
|
-
# Batch from a JSON file with custom concurrency
|
|
242
|
-
pplx -I queries.json -o jsonl -c 5 -t 30000
|
|
243
33
|
```
|
|
244
34
|
|
|
245
|
-
|
|
246
|
-
```json
|
|
247
|
-
{
|
|
248
|
-
"version": "1.0.0",
|
|
249
|
-
"requests": [
|
|
250
|
-
{ "op": "search", "args": { "query": "AI trends", "maxResults": 5 } },
|
|
251
|
-
{ "op": "search", "args": { "query": "TypeScript patterns", "maxResults": 3 } }
|
|
252
|
-
],
|
|
253
|
-
"options": { "concurrency": 5, "timeoutMs": 30000 }
|
|
254
|
-
}
|
|
255
|
-
```
|
|
35
|
+
## Setup
|
|
256
36
|
|
|
257
|
-
|
|
37
|
+
Get your API key from [Perplexity Settings](https://www.perplexity.ai/settings/api).
|
|
258
38
|
|
|
259
39
|
```bash
|
|
260
|
-
|
|
261
|
-
pplx --async --webhook http://localhost:3000/callback "long research task"
|
|
262
|
-
|
|
263
|
-
# Export results to file
|
|
264
|
-
pplx --export results.json "machine learning trends"
|
|
265
|
-
|
|
266
|
-
# Search with custom result limits
|
|
267
|
-
pplx -n 10 "latest web development frameworks"
|
|
268
|
-
|
|
269
|
-
# Query from stdin (for pipelines)
|
|
270
|
-
echo '{"query": "best practices for API design"}' | pplx -s
|
|
40
|
+
export PERPLEXITY_API_KEY="pplx-..."
|
|
271
41
|
```
|
|
272
42
|
|
|
273
|
-
|
|
43
|
+
## Usage
|
|
274
44
|
|
|
275
45
|
```bash
|
|
276
|
-
#
|
|
277
|
-
pplx
|
|
278
|
-
|
|
279
|
-
# Data analyst: Extract insights from datasets
|
|
280
|
-
pplx -f sales_data.csv -i revenue_chart.png "identify growth opportunities"
|
|
281
|
-
|
|
282
|
-
# Developer: Code review and optimization
|
|
283
|
-
pplx -f app.py --attach perf_metrics.json "suggest performance improvements"
|
|
284
|
-
|
|
285
|
-
# Product manager: Competitive analysis
|
|
286
|
-
pplx -f competitor_data.pdf "summarize key differentiators and market position"
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## 📋 Command Reference
|
|
293
|
-
|
|
294
|
-
### Main Options
|
|
295
|
-
|
|
296
|
-
| Flag | Short | Description | Example |
|
|
297
|
-
|------|-------|-------------|---------|
|
|
298
|
-
| `--model` | `-m` | AI model to use | `-m sonar-pro` |
|
|
299
|
-
| `--max-results` | `-n` | Max results per query (1-20) | `-n 10` |
|
|
300
|
-
| `--file` | `-f` | Attach document for analysis | `-f report.pdf` |
|
|
301
|
-
| `--image` | `-i` | Attach image for analysis | `-i screenshot.png` |
|
|
302
|
-
| `--format` | `-o` | Output format: json/jsonl | `-o jsonl` |
|
|
303
|
-
| `--query` | `-q` | Search query (alternative to positional) | `-q "search term"` |
|
|
304
|
-
| `--export` | | Export results to file | `--export results.json` |
|
|
305
|
-
| `--input` | `-I` | Read queries from JSON file | `-I batch.json` |
|
|
306
|
-
| `--stdin` | `-s` | Read queries from stdin | `cat query.json \| pplx -s` |
|
|
307
|
-
| `--attach` | | Additional file attachments | `--attach file1.pdf --attach file2.txt` |
|
|
308
|
-
| `--attach-image` | | Additional image attachments | `--attach-image img1.png --attach-image img2.jpg` |
|
|
309
|
-
| `--async` | | Enable async mode for advanced models | `--async` |
|
|
310
|
-
| `--webhook` | | Webhook URL for async results | `--webhook http://localhost:3000` |
|
|
311
|
-
| `--workspace` | | Workspace directory for file operations | `--workspace ./project` |
|
|
312
|
-
| `--use-search-api` | | Use search API (default: true) | `--use-search-api` |
|
|
313
|
-
| `--batch-size` | | Batch size for processing (1-100) | `--batch-size 50` |
|
|
314
|
-
|
|
315
|
-
### Performance & Control
|
|
316
|
-
|
|
317
|
-
| Flag | Description | Default | Range |
|
|
318
|
-
|------|-------------|---------|-------|
|
|
319
|
-
| `--concurrency` | Max parallel requests for batch operations | 5 | 1-20 |
|
|
320
|
-
| `--timeout` | Request timeout in milliseconds | 30000 | 1000-300000 |
|
|
321
|
-
|
|
322
|
-
### Utility Commands
|
|
46
|
+
# Quick search
|
|
47
|
+
pplx "best practices for error handling in typescript"
|
|
323
48
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
| `update --check` | Check for available updates | `pplx update --check` |
|
|
327
|
-
| `update --auto` | Install updates and relaunch | `pplx update --auto` |
|
|
328
|
-
| `history [limit]` | Show search history | `pplx history 10` |
|
|
329
|
-
| `version` | Show version information | `pplx version` |
|
|
330
|
-
| `--help` | Show help message | `pplx --help` |
|
|
331
|
-
| `--version` | Show version number | `pplx --version` |
|
|
49
|
+
# Use a more powerful model
|
|
50
|
+
pplx -m sonar-pro "explain quantum entanglement simply"
|
|
332
51
|
|
|
333
|
-
|
|
52
|
+
# Deep research mode (takes longer, more comprehensive)
|
|
53
|
+
pplx -m sonar-deep-research "comprehensive analysis of AI regulation in 2024"
|
|
334
54
|
|
|
335
|
-
|
|
336
|
-
-
|
|
337
|
-
- CSV, JSON (structured data)
|
|
338
|
-
- XML, YAML (configuration files)
|
|
55
|
+
# Analyze a document
|
|
56
|
+
pplx -f report.pdf "summarize the key findings"
|
|
339
57
|
|
|
340
|
-
|
|
341
|
-
-
|
|
342
|
-
- BMP, TIFF (legacy formats)
|
|
58
|
+
# Describe an image
|
|
59
|
+
pplx -i screenshot.png "what's happening in this image"
|
|
343
60
|
|
|
344
|
-
|
|
61
|
+
# Continue a conversation
|
|
62
|
+
pplx "what is rust"
|
|
63
|
+
pplx -c "how does it compare to go?"
|
|
64
|
+
pplx -c "which should I learn first?"
|
|
345
65
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
| `sonar` | Quick answers, general queries | ⚡ Fast | Standard detail |
|
|
349
|
-
| `sonar-pro` | Detailed analysis, research | 🚀 Fast | Enhanced detail |
|
|
350
|
-
| `sonar-reasoning` | Mathematical reasoning, logic | 🐢 Moderate | Step-by-step |
|
|
351
|
-
| `sonar-deep-research` | Comprehensive research with web context | 🐌 Slow | Maximum detail |
|
|
66
|
+
# Save research to markdown
|
|
67
|
+
pplx -m sonar-deep-research "AI trends 2025" -o research.md
|
|
352
68
|
|
|
353
|
-
|
|
69
|
+
# Get JSON output for scripting
|
|
70
|
+
pplx --json "capital of france" | jq .answer
|
|
354
71
|
|
|
355
|
-
|
|
72
|
+
# View query history
|
|
73
|
+
pplx --history
|
|
356
74
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
Use the toolkit directly in TypeScript when embedding into agents or services.
|
|
360
|
-
|
|
361
|
-
```ts
|
|
362
|
-
import { PerplexitySearchTool } from 'pplx-zero';
|
|
363
|
-
|
|
364
|
-
// Initialize the search tool
|
|
365
|
-
const tool = new PerplexitySearchTool();
|
|
366
|
-
|
|
367
|
-
// Single search query
|
|
368
|
-
const result = await tool.search({
|
|
369
|
-
query: "TypeScript best practices",
|
|
370
|
-
model: "sonar-pro",
|
|
371
|
-
maxResults: 5
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
console.log(result);
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
### Batch Processing
|
|
378
|
-
|
|
379
|
-
```ts
|
|
380
|
-
import { PerplexitySearchTool } from 'pplx-zero';
|
|
381
|
-
|
|
382
|
-
const tool = new PerplexitySearchTool();
|
|
383
|
-
|
|
384
|
-
// Batch search with custom configuration
|
|
385
|
-
const batchResult = await tool.runBatch({
|
|
386
|
-
version: "1.0.0",
|
|
387
|
-
requests: [
|
|
388
|
-
{
|
|
389
|
-
op: "search",
|
|
390
|
-
args: {
|
|
391
|
-
query: "TypeScript best practices",
|
|
392
|
-
maxResults: 5,
|
|
393
|
-
model: "sonar-pro"
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
op: "search",
|
|
398
|
-
args: {
|
|
399
|
-
query: "React performance optimization",
|
|
400
|
-
maxResults: 3,
|
|
401
|
-
model: "sonar"
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
],
|
|
405
|
-
options: {
|
|
406
|
-
concurrency: 3,
|
|
407
|
-
timeoutMs: 30000
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
console.log('Batch results:', batchResult);
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
### Advanced Usage with Error Handling
|
|
415
|
-
|
|
416
|
-
```ts
|
|
417
|
-
import { PerplexitySearchTool } from 'pplx-zero';
|
|
418
|
-
|
|
419
|
-
async function searchWithRetry(query: string, maxRetries = 3) {
|
|
420
|
-
const tool = new PerplexitySearchTool();
|
|
421
|
-
|
|
422
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
423
|
-
try {
|
|
424
|
-
const result = await tool.search({
|
|
425
|
-
query,
|
|
426
|
-
model: "sonar-pro",
|
|
427
|
-
maxResults: 5
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
return result;
|
|
431
|
-
} catch (error) {
|
|
432
|
-
if (attempt === maxRetries) {
|
|
433
|
-
throw new Error(`Search failed after ${maxRetries} attempts: ${error}`);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Exponential backoff
|
|
437
|
-
await new Promise(resolve => setTimeout(resolve, Math.pow(2, attempt) * 1000));
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Usage
|
|
443
|
-
searchWithRetry("latest AI trends")
|
|
444
|
-
.then(result => console.log(result))
|
|
445
|
-
.catch(error => console.error(error));
|
|
75
|
+
# Search without saving to history
|
|
76
|
+
pplx --no-history "sensitive query"
|
|
446
77
|
```
|
|
447
78
|
|
|
448
|
-
|
|
79
|
+
## Models
|
|
449
80
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
export PERPLEXITY_API_KEY="your-api-key"
|
|
458
|
-
|
|
459
|
-
# Verify key is set
|
|
460
|
-
echo $PERPLEXITY_API_KEY
|
|
461
|
-
```
|
|
81
|
+
| Model | Best For |
|
|
82
|
+
|-------|----------|
|
|
83
|
+
| `sonar` | Quick answers (default) |
|
|
84
|
+
| `sonar-pro` | Complex questions |
|
|
85
|
+
| `sonar-reasoning` | Step-by-step thinking |
|
|
86
|
+
| `sonar-reasoning-pro` | Advanced reasoning |
|
|
87
|
+
| `sonar-deep-research` | Comprehensive research |
|
|
462
88
|
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
# Error: "File too large" (files must be < 50MB)
|
|
466
|
-
ls -lh your-file.pdf
|
|
89
|
+
## Options
|
|
467
90
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
91
|
+
| Flag | Description |
|
|
92
|
+
|------|-------------|
|
|
93
|
+
| `-m, --model <name>` | Select model |
|
|
94
|
+
| `-f, --file <path>` | Attach document (PDF, TXT, MD, etc.) |
|
|
95
|
+
| `-i, --image <path>` | Attach image (PNG, JPG, WebP, etc.) |
|
|
96
|
+
| `-o, --output <path>` | Save output to file (.md, .txt) |
|
|
97
|
+
| `-c, --continue` | Continue from last query |
|
|
98
|
+
| `--history` | Show query history |
|
|
99
|
+
| `--no-history` | Don't save query to history |
|
|
100
|
+
| `--json` | Output as JSON |
|
|
101
|
+
| `-h, --help` | Show help |
|
|
471
102
|
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
# Increase timeout for complex queries
|
|
475
|
-
pplx -t 60000 "complex research question"
|
|
103
|
+
## History & Sessions
|
|
476
104
|
|
|
477
|
-
|
|
478
|
-
curl -I https://api.perplexity.ai
|
|
479
|
-
```
|
|
105
|
+
pplx-zero keeps a local history of your queries at `~/.pplx/history.jsonl`.
|
|
480
106
|
|
|
481
|
-
#### Permission Issues
|
|
482
107
|
```bash
|
|
483
|
-
#
|
|
484
|
-
|
|
108
|
+
# View recent queries
|
|
109
|
+
pplx --history
|
|
485
110
|
|
|
486
|
-
#
|
|
487
|
-
|
|
488
|
-
```
|
|
111
|
+
# Filter with grep
|
|
112
|
+
pplx --history | grep "typescript"
|
|
489
113
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
```bash
|
|
493
|
-
# Enable verbose output for debugging
|
|
494
|
-
DEBUG=pplx:* pplx "your query"
|
|
114
|
+
# Continue last conversation
|
|
115
|
+
pplx -c "tell me more"
|
|
495
116
|
|
|
496
|
-
#
|
|
497
|
-
pplx --
|
|
498
|
-
pplx update --check
|
|
117
|
+
# Skip history for sensitive queries
|
|
118
|
+
pplx --no-history "private question"
|
|
499
119
|
```
|
|
500
120
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
| Scenario | Recommended Settings |
|
|
504
|
-
|----------|---------------------|
|
|
505
|
-
| **Quick searches** | Default settings (sonar model) |
|
|
506
|
-
| **Deep research** | `-m sonar-deep-research -t 60000` |
|
|
507
|
-
| **Batch processing** | `-c 10 -t 45000` |
|
|
508
|
-
| **File analysis** | `-m sonar-pro -t 60000` |
|
|
509
|
-
| **Real-time queries** | `-m sonar -n 3` |
|
|
510
|
-
|
|
511
|
-
---
|
|
512
|
-
|
|
513
|
-
## 📚 Additional Resources
|
|
514
|
-
|
|
515
|
-
- **GitHub Repository**: [github.com/codewithkenzo/pplx-zero](https://github.com/codewithkenzo/pplx-zero)
|
|
516
|
-
- **Bug Reports & Issues**: [GitHub Issues](https://github.com/codewithkenzo/pplx-zero/issues)
|
|
517
|
-
- **Perplexity API Documentation**: [docs.perplexity.ai](https://docs.perplexity.ai)
|
|
518
|
-
- **Model Comparison**: Detailed model comparison in the [AI Models](#ai-models) section above
|
|
121
|
+
History auto-rotates at 1000 entries to keep the file small.
|
|
519
122
|
|
|
520
|
-
|
|
123
|
+
## Exit Codes
|
|
521
124
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
# Check for updates
|
|
529
|
-
pplx update --check
|
|
530
|
-
|
|
531
|
-
# Auto-update
|
|
532
|
-
pplx update --auto
|
|
533
|
-
|
|
534
|
-
# Show version
|
|
535
|
-
pplx --version
|
|
536
|
-
|
|
537
|
-
# Search history
|
|
538
|
-
pplx history 10
|
|
539
|
-
|
|
540
|
-
# Quick test
|
|
541
|
-
pplx "test query"
|
|
542
|
-
```
|
|
125
|
+
| Code | Meaning |
|
|
126
|
+
|------|---------|
|
|
127
|
+
| `0` | Success |
|
|
128
|
+
| `1` | API error |
|
|
129
|
+
| `2` | Configuration error |
|
|
543
130
|
|
|
544
|
-
|
|
131
|
+
## License
|
|
545
132
|
|
|
546
|
-
|
|
133
|
+
MIT
|
package/bin/pplx.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn, execSync } = require('child_process');
|
|
4
|
+
const { join } = require('path');
|
|
5
|
+
|
|
6
|
+
const hasBun = () => {
|
|
7
|
+
try {
|
|
8
|
+
execSync('bun --version', { stdio: 'ignore' });
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (hasBun()) {
|
|
16
|
+
const scriptPath = join(__dirname, '..', 'src', 'index.ts');
|
|
17
|
+
const proc = spawn('bun', ['run', scriptPath, ...process.argv.slice(2)], {
|
|
18
|
+
stdio: 'inherit'
|
|
19
|
+
});
|
|
20
|
+
proc.on('exit', (code) => process.exit(code ?? 1));
|
|
21
|
+
} else {
|
|
22
|
+
console.error('\x1b[31mError: pplx-zero requires Bun to be installed.\x1b[0m');
|
|
23
|
+
console.error('\nInstall Bun:');
|
|
24
|
+
console.error(' curl -fsSL https://bun.sh/install | bash');
|
|
25
|
+
console.error('\nOr via npm:');
|
|
26
|
+
console.error(' npm install -g bun');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|