@victor-software-house/pi-openai-proxy 4.2.1 → 4.2.2
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 +30 -57
- package/package.json +1 -1
package/extensions/proxy.ts
CHANGED
|
@@ -552,71 +552,44 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
552
552
|
): Component {
|
|
553
553
|
const models = getAvailableModels();
|
|
554
554
|
const selected = new Set(config.customModels);
|
|
555
|
-
let selectedIndex = 0;
|
|
556
555
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
return {
|
|
569
|
-
render(width: number): string[] {
|
|
570
|
-
const lines: string[] = [];
|
|
571
|
-
lines.push(" Select models (Space: toggle, Esc: done)");
|
|
572
|
-
lines.push("");
|
|
556
|
+
const items: SettingItem[] = models.map((m) => {
|
|
557
|
+
const canonical = `${m.provider}/${m.id}`;
|
|
558
|
+
return {
|
|
559
|
+
id: canonical,
|
|
560
|
+
label: canonical,
|
|
561
|
+
currentValue: selected.has(canonical) ? "[x]" : "[ ]",
|
|
562
|
+
values: ["[x]", "[ ]"],
|
|
563
|
+
};
|
|
564
|
+
});
|
|
573
565
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
);
|
|
584
|
-
const end = Math.min(start + maxVisible, models.length);
|
|
585
|
-
|
|
586
|
-
for (let i = start; i < end; i++) {
|
|
587
|
-
const m = models[i];
|
|
588
|
-
if (m === undefined) continue;
|
|
589
|
-
const canonical = `${m.provider}/${m.id}`;
|
|
590
|
-
const check = selected.has(canonical) ? "[x]" : "[ ]";
|
|
591
|
-
const cursor = i === selectedIndex ? "> " : " ";
|
|
592
|
-
const line = `${cursor}${check} ${canonical}`;
|
|
593
|
-
const truncated = line.length > width ? line.slice(0, width - 1) : line;
|
|
594
|
-
lines.push(truncated);
|
|
566
|
+
const list = new SettingsList(
|
|
567
|
+
items,
|
|
568
|
+
Math.min(items.length + 2, 20),
|
|
569
|
+
getSettingsListTheme(),
|
|
570
|
+
(id: string, newValue: string) => {
|
|
571
|
+
if (newValue === "[x]") {
|
|
572
|
+
selected.add(id);
|
|
573
|
+
} else {
|
|
574
|
+
selected.delete(id);
|
|
595
575
|
}
|
|
576
|
+
config = { ...config, customModels: [...selected] };
|
|
577
|
+
saveConfigToFile(config);
|
|
578
|
+
config = loadConfigFromFile();
|
|
579
|
+
},
|
|
580
|
+
() => done(`${String(selected.size)} selected`),
|
|
581
|
+
{ enableSearch: true },
|
|
582
|
+
);
|
|
596
583
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return
|
|
584
|
+
return {
|
|
585
|
+
render(width: number): string[] {
|
|
586
|
+
return list.render(width);
|
|
600
587
|
},
|
|
601
588
|
invalidate(): void {
|
|
602
|
-
|
|
589
|
+
list.invalidate();
|
|
603
590
|
},
|
|
604
591
|
handleInput(data: string): void {
|
|
605
|
-
|
|
606
|
-
done(`${String(selected.size)} selected`);
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
if (models.length === 0) return;
|
|
610
|
-
if (data === "\x1B[A") {
|
|
611
|
-
selectedIndex = selectedIndex <= 0 ? models.length - 1 : selectedIndex - 1;
|
|
612
|
-
} else if (data === "\x1B[B") {
|
|
613
|
-
selectedIndex = selectedIndex >= models.length - 1 ? 0 : selectedIndex + 1;
|
|
614
|
-
} else if (data === " " || data === "\r") {
|
|
615
|
-
const m = models[selectedIndex];
|
|
616
|
-
if (m !== undefined) {
|
|
617
|
-
toggle(`${m.provider}/${m.id}`);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
592
|
+
list.handleInput(data);
|
|
620
593
|
},
|
|
621
594
|
};
|
|
622
595
|
}
|
package/package.json
CHANGED