@victor-software-house/pi-openai-proxy 4.2.6 → 4.3.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 +52 -1
- package/package.json +1 -1
package/extensions/proxy.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* /proxy stop Stop the proxy server
|
|
8
8
|
* /proxy status Show proxy status
|
|
9
9
|
* /proxy verify Validate model exposure config against available models
|
|
10
|
+
* /proxy models List all exposed models with their public IDs
|
|
10
11
|
* /proxy config Open settings panel (alias)
|
|
11
12
|
* /proxy show Summarize current config and exposure policy
|
|
12
13
|
* /proxy path Show config file location
|
|
@@ -137,13 +138,14 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
137
138
|
"restart",
|
|
138
139
|
"status",
|
|
139
140
|
"verify",
|
|
141
|
+
"models",
|
|
140
142
|
"config",
|
|
141
143
|
"show",
|
|
142
144
|
"path",
|
|
143
145
|
"reset",
|
|
144
146
|
"help",
|
|
145
147
|
];
|
|
146
|
-
const USAGE = "/proxy [start|stop|restart|status|verify|config|show|path|reset|help]";
|
|
148
|
+
const USAGE = "/proxy [start|stop|restart|status|verify|models|config|show|path|reset|help]";
|
|
147
149
|
|
|
148
150
|
pi.registerCommand("proxy", {
|
|
149
151
|
description: "Manage the OpenAI-compatible proxy",
|
|
@@ -173,6 +175,9 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
173
175
|
case "verify":
|
|
174
176
|
verifyExposure(ctx);
|
|
175
177
|
return;
|
|
178
|
+
case "models":
|
|
179
|
+
showModels(ctx);
|
|
180
|
+
return;
|
|
176
181
|
case "show":
|
|
177
182
|
showConfig(ctx);
|
|
178
183
|
return;
|
|
@@ -476,6 +481,52 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
476
481
|
ctx.ui.notify(`${serverLines.join(" | ")}\n${exposureLines.join(" | ")}`, "info");
|
|
477
482
|
}
|
|
478
483
|
|
|
484
|
+
// --- /proxy models ---
|
|
485
|
+
|
|
486
|
+
function showModels(ctx: ExtensionContext): void {
|
|
487
|
+
config = loadConfigFromFile();
|
|
488
|
+
const models = getAvailableModels();
|
|
489
|
+
const allModels = getAllRegisteredModels();
|
|
490
|
+
const outcome = computeModelExposure(models, allModels, buildExposureConfig());
|
|
491
|
+
|
|
492
|
+
if (!outcome.ok) {
|
|
493
|
+
ctx.ui.notify(`Model exposure error: ${outcome.message}`, "warning");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (outcome.models.length === 0) {
|
|
498
|
+
ctx.ui.notify("No models exposed. Check /proxy verify for details.", "info");
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Group models by provider for readable output
|
|
503
|
+
const byProvider = new Map<string, { publicId: string; canonicalId: string }[]>();
|
|
504
|
+
for (const m of outcome.models) {
|
|
505
|
+
const list = byProvider.get(m.provider);
|
|
506
|
+
const entry = { publicId: m.publicId, canonicalId: m.canonicalId };
|
|
507
|
+
if (list !== undefined) {
|
|
508
|
+
list.push(entry);
|
|
509
|
+
} else {
|
|
510
|
+
byProvider.set(m.provider, [entry]);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const sections: string[] = [];
|
|
515
|
+
for (const [provider, entries] of byProvider) {
|
|
516
|
+
const lines = entries.map((e) => {
|
|
517
|
+
// Only show canonical ID when it differs from the public ID
|
|
518
|
+
if (e.publicId === e.canonicalId) {
|
|
519
|
+
return ` ${e.publicId}`;
|
|
520
|
+
}
|
|
521
|
+
return ` ${e.publicId} (${e.canonicalId})`;
|
|
522
|
+
});
|
|
523
|
+
sections.push(`${provider} (${String(entries.length)}):\n${lines.join("\n")}`);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const header = `${String(outcome.models.length)} exposed model(s)`;
|
|
527
|
+
ctx.ui.notify(`${header}\n\n${sections.join("\n\n")}`, "info");
|
|
528
|
+
}
|
|
529
|
+
|
|
479
530
|
// --- /proxy verify ---
|
|
480
531
|
|
|
481
532
|
function verifyExposure(ctx: ExtensionContext): void {
|
package/package.json
CHANGED