pplx-cli 1.0.0 → 1.0.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/dist/index.js +6 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2853,10 +2853,11 @@ class PerplexityClient {
|
|
|
2853
2853
|
}
|
|
2854
2854
|
}
|
|
2855
2855
|
async search(request) {
|
|
2856
|
+
const cleanRequest = Object.fromEntries(Object.entries(request).filter(([_, v]) => v !== undefined));
|
|
2856
2857
|
const response = await fetch(`${API_BASE_URL}/search`, {
|
|
2857
2858
|
method: "POST",
|
|
2858
2859
|
headers: this.getHeaders(),
|
|
2859
|
-
body: JSON.stringify(
|
|
2860
|
+
body: JSON.stringify(cleanRequest)
|
|
2860
2861
|
});
|
|
2861
2862
|
if (!response.ok) {
|
|
2862
2863
|
const error = await response.text();
|
|
@@ -5691,7 +5692,7 @@ function createAskCommand() {
|
|
|
5691
5692
|
|
|
5692
5693
|
// src/commands/search.ts
|
|
5693
5694
|
function createSearchCommand() {
|
|
5694
|
-
return new Command("search").description("Search the web using Perplexity").argument("<query>", "The search query").option("-l, --limit <number>", "Maximum number of results", "10").option("-
|
|
5695
|
+
return new Command("search").description("Search the web using Perplexity").argument("<query>", "The search query").option("-l, --limit <number>", "Maximum number of results", "10").option("-r, --recency <recency>", "Filter by recency (hour, day, week, month, year)").option("-d, --domain <domains...>", "Filter by domain(s)").option("--language <languages...>", "Filter by language(s) using ISO codes (e.g., en, fr, de)").option("--country <code>", "Filter by country using ISO code (e.g., US, GB, IN)").option("-j, --json", "Output raw JSON response", false).action(async (query, options) => {
|
|
5695
5696
|
const apiKey = getApiKey();
|
|
5696
5697
|
if (!apiKey) {
|
|
5697
5698
|
console.log(formatError("No API key configured."));
|
|
@@ -5699,12 +5700,6 @@ function createSearchCommand() {
|
|
|
5699
5700
|
console.log(source_default.dim("Or set the PERPLEXITY_API_KEY environment variable."));
|
|
5700
5701
|
process.exit(1);
|
|
5701
5702
|
}
|
|
5702
|
-
const validModes = ["web", "academic", "sec"];
|
|
5703
|
-
if (!validModes.includes(options.mode)) {
|
|
5704
|
-
console.log(formatError(`Invalid mode: ${options.mode}`));
|
|
5705
|
-
console.log(source_default.dim(`Valid modes: ${validModes.join(", ")}`));
|
|
5706
|
-
process.exit(1);
|
|
5707
|
-
}
|
|
5708
5703
|
const validRecency = ["hour", "day", "week", "month", "year"];
|
|
5709
5704
|
if (options.recency && !validRecency.includes(options.recency)) {
|
|
5710
5705
|
console.log(formatError(`Invalid recency: ${options.recency}`));
|
|
@@ -5718,9 +5713,10 @@ function createSearchCommand() {
|
|
|
5718
5713
|
const response = await client.search({
|
|
5719
5714
|
query,
|
|
5720
5715
|
max_results: parseInt(options.limit, 10),
|
|
5721
|
-
search_mode: options.mode,
|
|
5722
5716
|
search_recency_filter: options.recency,
|
|
5723
|
-
search_domain_filter: options.domain
|
|
5717
|
+
search_domain_filter: options.domain,
|
|
5718
|
+
search_language_filter: options.language,
|
|
5719
|
+
country: options.country
|
|
5724
5720
|
});
|
|
5725
5721
|
spinner.stop();
|
|
5726
5722
|
if (options.json) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pplx-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A powerful CLI tool for the Perplexity AI API - search the web and chat with AI from your terminal",
|
|
5
5
|
"author": "Adarsh Dubey",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=18"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|