@victor-software-house/pi-openai-proxy 3.0.0 → 4.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/extensions/proxy.ts +11 -15
- package/package.json +1 -1
package/extensions/proxy.ts
CHANGED
|
@@ -83,6 +83,12 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
83
83
|
return registry.getAvailable();
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
function getAllRegisteredModels(): Model<Api>[] {
|
|
87
|
+
const auth = AuthStorage.create();
|
|
88
|
+
const registry = new ModelRegistry(auth);
|
|
89
|
+
return registry.getAll();
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
function getUniqueProviders(models: readonly Model<Api>[]): string[] {
|
|
87
93
|
const seen = new Set<string>();
|
|
88
94
|
for (const m of models) {
|
|
@@ -453,7 +459,8 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
453
459
|
|
|
454
460
|
// Public ID preview (first 5 exposed models)
|
|
455
461
|
const models = getAvailableModels();
|
|
456
|
-
const
|
|
462
|
+
const allModels = getAllRegisteredModels();
|
|
463
|
+
const outcome = computeModelExposure(models, allModels, buildExposureConfig());
|
|
457
464
|
if (outcome.ok && outcome.models.length > 0) {
|
|
458
465
|
const preview = outcome.models.slice(0, 5).map((m) => m.publicId);
|
|
459
466
|
const suffix =
|
|
@@ -475,24 +482,13 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
475
482
|
const models = getAvailableModels();
|
|
476
483
|
const issues: string[] = [];
|
|
477
484
|
|
|
485
|
+
const allModels = getAllRegisteredModels();
|
|
486
|
+
|
|
478
487
|
// Check available models
|
|
479
488
|
if (models.length === 0) {
|
|
480
489
|
issues.push("No models have auth configured. The proxy will expose 0 models.");
|
|
481
490
|
}
|
|
482
491
|
|
|
483
|
-
// Check scoped providers reference valid providers
|
|
484
|
-
if (config.modelExposureMode === "scoped") {
|
|
485
|
-
const availableProviders = new Set(getUniqueProviders(models));
|
|
486
|
-
for (const p of config.scopedProviders) {
|
|
487
|
-
if (!availableProviders.has(p)) {
|
|
488
|
-
issues.push(`Scoped provider '${p}' has no available models (no auth or unknown).`);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
if (config.scopedProviders.length === 0) {
|
|
492
|
-
issues.push("Scoped mode with empty provider list will expose 0 models.");
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
492
|
// Check custom models reference valid canonical IDs
|
|
497
493
|
if (config.modelExposureMode === "custom") {
|
|
498
494
|
const canonicalSet = new Set(models.map((m) => `${m.provider}/${m.id}`));
|
|
@@ -507,7 +503,7 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
507
503
|
}
|
|
508
504
|
|
|
509
505
|
// Run the full exposure computation to catch ID/prefix errors
|
|
510
|
-
const outcome = computeModelExposure(models, buildExposureConfig());
|
|
506
|
+
const outcome = computeModelExposure(models, allModels, buildExposureConfig());
|
|
511
507
|
if (!outcome.ok) {
|
|
512
508
|
issues.push(outcome.message);
|
|
513
509
|
}
|
package/package.json
CHANGED