pplx-zero 1.1.8 → 2.0.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 +23 -523
- 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/index.ts +96 -0
- package/src/output.test.ts +41 -0
- package/src/output.ts +28 -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,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pplx-zero
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Minimal Perplexity AI CLI - search from terminal.
|
|
4
4
|
|
|
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)
|
|
5
|
+
## Installation
|
|
23
6
|
|
|
24
7
|
```bash
|
|
25
|
-
# npm or bun (global)
|
|
26
|
-
npm install -g pplx-zero
|
|
27
|
-
# or
|
|
28
8
|
bun install -g pplx-zero
|
|
29
|
-
|
|
30
|
-
# Verify installation
|
|
31
|
-
pplx --version
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### 📦 Binary Download (No Node.js required)
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Download the appropriate binary for your platform
|
|
38
|
-
# Linux (x64) - Most servers and desktops
|
|
39
|
-
wget https://github.com/codewithkenzo/pplx-zero/releases/latest/download/pplx-v1.1.7-linux-x64
|
|
40
|
-
chmod +x pplx-v1.1.7-linux-x64
|
|
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
|
-
```
|
|
62
|
-
|
|
63
|
-
**Alternative Installation Script (Linux/macOS):**
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# Automated installation script
|
|
67
|
-
curl -sSL https://github.com/codewithkenzo/pplx-zero/releases/latest/download/pplx-v1.1.7-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/') -o pplx
|
|
68
|
-
chmod +x pplx
|
|
69
|
-
sudo mv pplx /usr/local/bin/pplx
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### 🏛️ AUR (Arch Linux)
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
# Using yay (recommended)
|
|
76
|
-
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
|
-
```
|
|
244
|
-
|
|
245
|
-
**Batch JSON format:**
|
|
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
|
-
```
|
|
256
|
-
|
|
257
|
-
### Advanced Workflows
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
# Fire-and-forget async with webhook callback
|
|
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
|
|
271
9
|
```
|
|
272
10
|
|
|
273
|
-
|
|
11
|
+
Or with npm:
|
|
274
12
|
|
|
275
13
|
```bash
|
|
276
|
-
|
|
277
|
-
pplx -f vuln_report.pdf --attach screenshots/ "explain security implications"
|
|
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
|
|
323
|
-
|
|
324
|
-
| Command | Description | Example |
|
|
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` |
|
|
332
|
-
|
|
333
|
-
### Supported File Formats
|
|
334
|
-
|
|
335
|
-
**Documents (up to 50MB):**
|
|
336
|
-
- PDF, DOC, DOCX, TXT, RTF, MD
|
|
337
|
-
- CSV, JSON (structured data)
|
|
338
|
-
- XML, YAML (configuration files)
|
|
339
|
-
|
|
340
|
-
**Images (up to 50MB):**
|
|
341
|
-
- PNG, JPEG, WebP, HEIF/HEIC, GIF
|
|
342
|
-
- BMP, TIFF (legacy formats)
|
|
343
|
-
|
|
344
|
-
### AI Models
|
|
345
|
-
|
|
346
|
-
| Model | Best For | Speed | Detail |
|
|
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 |
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
## 💻 Programmatic Use
|
|
356
|
-
|
|
357
|
-
### TypeScript API
|
|
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));
|
|
14
|
+
npm install -g pplx-zero
|
|
446
15
|
```
|
|
447
16
|
|
|
448
|
-
|
|
17
|
+
## Setup
|
|
449
18
|
|
|
450
|
-
## 🛠️ Troubleshooting
|
|
451
|
-
|
|
452
|
-
### Common Issues & Solutions
|
|
453
|
-
|
|
454
|
-
#### API Key Problems
|
|
455
19
|
```bash
|
|
456
|
-
# Error: "API key not found"
|
|
457
20
|
export PERPLEXITY_API_KEY="your-api-key"
|
|
458
|
-
|
|
459
|
-
# Verify key is set
|
|
460
|
-
echo $PERPLEXITY_API_KEY
|
|
461
21
|
```
|
|
462
22
|
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
# Error: "File too large" (files must be < 50MB)
|
|
466
|
-
ls -lh your-file.pdf
|
|
467
|
-
|
|
468
|
-
# Supported formats check
|
|
469
|
-
file your-document.pdf # Should show PDF format
|
|
470
|
-
```
|
|
23
|
+
## Usage
|
|
471
24
|
|
|
472
|
-
#### Network/Timeout Issues
|
|
473
25
|
```bash
|
|
474
|
-
|
|
475
|
-
pplx -
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
26
|
+
pplx "what is bun"
|
|
27
|
+
pplx -m sonar-pro "explain quantum computing"
|
|
28
|
+
pplx -m sonar-deep-research "comprehensive analysis of AI trends"
|
|
29
|
+
pplx -f report.pdf "summarize this document"
|
|
30
|
+
pplx -i screenshot.png "what's in this image"
|
|
31
|
+
pplx --json "get structured response"
|
|
479
32
|
```
|
|
480
33
|
|
|
481
|
-
|
|
482
|
-
```bash
|
|
483
|
-
# Permission denied during installation
|
|
484
|
-
npm install -g pplx-zero --unsafe-perm
|
|
34
|
+
## Options
|
|
485
35
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
# Enable verbose output for debugging
|
|
494
|
-
DEBUG=pplx:* pplx "your query"
|
|
495
|
-
|
|
496
|
-
# Check configuration
|
|
497
|
-
pplx --version
|
|
498
|
-
pplx update --check
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
### Performance Tips
|
|
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
|
|
519
|
-
|
|
520
|
-
---
|
|
521
|
-
|
|
522
|
-
### Quick Reference Commands
|
|
523
|
-
|
|
524
|
-
```bash
|
|
525
|
-
# Show all available options
|
|
526
|
-
pplx --help
|
|
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
|
-
```
|
|
36
|
+
| Flag | Description |
|
|
37
|
+
|------|-------------|
|
|
38
|
+
| `-m, --model` | Model: sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro, sonar-deep-research |
|
|
39
|
+
| `-f, --file` | Attach a file (PDF, TXT, etc.) |
|
|
40
|
+
| `-i, --image` | Attach an image (PNG, JPG, etc.) |
|
|
41
|
+
| `--json` | Output as JSON |
|
|
42
|
+
| `-h, --help` | Show help |
|
|
543
43
|
|
|
544
|
-
|
|
44
|
+
## License
|
|
545
45
|
|
|
546
|
-
|
|
46
|
+
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
|
+
}
|