@iservu-inc/adf-cli 0.14.3 → 0.14.5
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/lib/ai/ai-client.js +5 -53
- package/lib/ai/ai-config.js +0 -43
- package/package.json +1 -1
package/lib/ai/ai-client.js
CHANGED
|
@@ -49,14 +49,6 @@ class AIClient {
|
|
|
49
49
|
});
|
|
50
50
|
break;
|
|
51
51
|
|
|
52
|
-
case 'perplexity':
|
|
53
|
-
const OpenAIForPerplexity = require('openai');
|
|
54
|
-
this.client = new OpenAIForPerplexity({
|
|
55
|
-
apiKey: this.apiKey,
|
|
56
|
-
baseURL: 'https://api.perplexity.ai'
|
|
57
|
-
});
|
|
58
|
-
break;
|
|
59
|
-
|
|
60
52
|
default:
|
|
61
53
|
throw new Error(`Unsupported provider: ${this.provider}`);
|
|
62
54
|
}
|
|
@@ -80,14 +72,11 @@ class AIClient {
|
|
|
80
72
|
case 'google':
|
|
81
73
|
return await this.googleRequest(prompt, maxTokens, temperature);
|
|
82
74
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
default: throw new Error(`Provider ${this.provider} not implemented`);
|
|
90
|
-
}
|
|
75
|
+
case 'openrouter':
|
|
76
|
+
return await this.openrouterRequest(prompt, maxTokens, temperature);
|
|
77
|
+
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Provider ${this.provider} not implemented`); }
|
|
91
80
|
} catch (error) {
|
|
92
81
|
throw new Error(`AI request failed: ${error.message}`);
|
|
93
82
|
}
|
|
@@ -322,43 +311,6 @@ class AIClient {
|
|
|
322
311
|
}
|
|
323
312
|
}
|
|
324
313
|
|
|
325
|
-
/**
|
|
326
|
-
* Perplexity AI request (via OpenAI-compatible API)
|
|
327
|
-
*/
|
|
328
|
-
async perplexityRequest(prompt, maxTokens, temperature) {
|
|
329
|
-
try {
|
|
330
|
-
// Perplexity supports standard OpenAI chat completions
|
|
331
|
-
// but has some specific recommended parameters
|
|
332
|
-
const response = await this.client.chat.completions.create({
|
|
333
|
-
model: this.model,
|
|
334
|
-
messages: [
|
|
335
|
-
{
|
|
336
|
-
role: 'user',
|
|
337
|
-
content: prompt
|
|
338
|
-
}
|
|
339
|
-
],
|
|
340
|
-
max_tokens: maxTokens,
|
|
341
|
-
temperature: temperature,
|
|
342
|
-
// Optional: Perplexity specific headers can be passed if needed via client config
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
return {
|
|
346
|
-
content: response.choices[0].message.content,
|
|
347
|
-
model: this.model,
|
|
348
|
-
provider: 'perplexity',
|
|
349
|
-
usage: {
|
|
350
|
-
promptTokens: response.usage?.prompt_tokens || 0,
|
|
351
|
-
completionTokens: response.usage?.completion_tokens || 0,
|
|
352
|
-
totalTokens: response.usage?.total_tokens || 0
|
|
353
|
-
},
|
|
354
|
-
// Include search citations if available (Perplexity feature)
|
|
355
|
-
citations: response.citations || []
|
|
356
|
-
};
|
|
357
|
-
} catch (error) {
|
|
358
|
-
throw new Error(`Perplexity request failed: ${error.message}`);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
314
|
/**
|
|
363
315
|
* Test connection with a simple prompt
|
|
364
316
|
*/
|
package/lib/ai/ai-config.js
CHANGED
|
@@ -70,20 +70,6 @@ const AI_PROVIDERS = {
|
|
|
70
70
|
'google/gemini-pro-1.5',
|
|
71
71
|
'meta-llama/llama-3.1-70b-instruct'
|
|
72
72
|
]
|
|
73
|
-
},
|
|
74
|
-
PERPLEXITY: {
|
|
75
|
-
id: 'perplexity',
|
|
76
|
-
name: 'Perplexity AI (Search + Reasoning)',
|
|
77
|
-
envVar: 'PERPLEXITY_API_KEY',
|
|
78
|
-
requiredFormat: 'pplx-',
|
|
79
|
-
website: 'https://www.perplexity.ai/api',
|
|
80
|
-
setup: 'Get your API key from https://www.perplexity.ai/settings/api',
|
|
81
|
-
defaultModels: [
|
|
82
|
-
'sonar-pro',
|
|
83
|
-
'sonar-reasoning-pro',
|
|
84
|
-
'sonar',
|
|
85
|
-
'sonar-deep-research'
|
|
86
|
-
]
|
|
87
73
|
}
|
|
88
74
|
};
|
|
89
75
|
|
|
@@ -395,35 +381,6 @@ async function fetchAvailableModels(provider, apiKey) {
|
|
|
395
381
|
console.log(chalk.yellow(' Using default model list\n'));
|
|
396
382
|
return provider.defaultModels;
|
|
397
383
|
|
|
398
|
-
case 'perplexity':
|
|
399
|
-
try {
|
|
400
|
-
// Perplexity doesn't have a list models endpoint, so we validate known ones
|
|
401
|
-
// by performing a very cheap token count or dry-run if possible,
|
|
402
|
-
// but for now we rely on the default list as it is static but we can try to validate
|
|
403
|
-
// the API key with a simple request to 'sonar' which is their fastest model.
|
|
404
|
-
const OpenAI = require('openai');
|
|
405
|
-
const client = new OpenAI({
|
|
406
|
-
apiKey,
|
|
407
|
-
baseURL: 'https://api.perplexity.ai'
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
// Simple validation check
|
|
411
|
-
await client.models.list(); // Some OpenAI compatible endpoints support this, let's try
|
|
412
|
-
|
|
413
|
-
// If list() works, we filter, otherwise we might fallback to defaults.
|
|
414
|
-
// Note: Perplexity API documentation says standard OpenAI endpoints are supported.
|
|
415
|
-
// If list() returns models, great. If not, we use defaults.
|
|
416
|
-
// However, Perplexity typically DOES NOT implement the /models endpoint fully dynamically
|
|
417
|
-
// like OpenAI. It often returns a static list or might error.
|
|
418
|
-
// Let's assume for safety we use the defaults but verified via a simple call.
|
|
419
|
-
|
|
420
|
-
spinner.succeed('Perplexity API connected');
|
|
421
|
-
return provider.defaultModels; // Return defaults as they are curated for the platform
|
|
422
|
-
} catch(error) {
|
|
423
|
-
spinner.warn(`Perplexity connectivity check failed: ${error.message}`);
|
|
424
|
-
}
|
|
425
|
-
return provider.defaultModels;
|
|
426
|
-
|
|
427
384
|
case 'openrouter':
|
|
428
385
|
try {
|
|
429
386
|
const fetch = require('node-fetch');
|