@iservu-inc/adf-cli 0.14.3 → 0.14.4
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-config.js +26 -0
- package/package.json +1 -1
package/lib/ai/ai-config.js
CHANGED
|
@@ -273,6 +273,27 @@ async function validateAPIKeyWithProvider(provider, apiKey, model = null) {
|
|
|
273
273
|
}
|
|
274
274
|
break;
|
|
275
275
|
|
|
276
|
+
case 'perplexity':
|
|
277
|
+
// Perplexity doesn't support models.list() fully in all tiers or it might be static.
|
|
278
|
+
// We use a cheap "models" list call if supported, or rely on the fact that
|
|
279
|
+
// if we can create a client and it doesn't crash, we assume it's good enough
|
|
280
|
+
// for this stage, effectively deferring full validation to model testing.
|
|
281
|
+
// However, we can try to hit the chat/completions endpoint with dry-run style if possible.
|
|
282
|
+
// For now, we will perform a lightweight check using OpenAI compatibility.
|
|
283
|
+
try {
|
|
284
|
+
const OpenAI = require('openai');
|
|
285
|
+
const client = new OpenAI({
|
|
286
|
+
apiKey,
|
|
287
|
+
baseURL: 'https://api.perplexity.ai'
|
|
288
|
+
});
|
|
289
|
+
// Try listing models (Perplexity supports this via OpenAI compatibility)
|
|
290
|
+
await client.models.list();
|
|
291
|
+
} catch (error) {
|
|
292
|
+
// If list models fails, the key is likely invalid
|
|
293
|
+
throw new Error(`Perplexity API validation failed: ${error.message}`);
|
|
294
|
+
}
|
|
295
|
+
break;
|
|
296
|
+
|
|
276
297
|
default:
|
|
277
298
|
throw new Error(`Validation not implemented for provider: ${provider.id}`);
|
|
278
299
|
}
|
|
@@ -571,6 +592,11 @@ async function configureAIProvider(projectPath = process.cwd()) {
|
|
|
571
592
|
name: buildProviderName(AI_PROVIDERS.OPENROUTER, 'openrouter'),
|
|
572
593
|
value: 'openrouter',
|
|
573
594
|
short: 'OpenRouter'
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
name: buildProviderName(AI_PROVIDERS.PERPLEXITY, 'perplexity'),
|
|
598
|
+
value: 'perplexity',
|
|
599
|
+
short: 'Perplexity'
|
|
574
600
|
}
|
|
575
601
|
];
|
|
576
602
|
|