@billjr99/pi-openai-compat 1.1.17 → 1.1.18
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/README.md +0 -23
- package/index.ts +3 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,26 +59,6 @@ If pi is already running when you install, type `/reload` first.
|
|
|
59
59
|
| **llmproxy** | `http://localhost:8080/v1` (editable) | Keyless by default; bearer token if your instance requires one |
|
|
60
60
|
| **Custom** | Any URL you supply | Optional bearer token |
|
|
61
61
|
|
|
62
|
-
> **The `__` → `/` model-id rewrite (display compatibility).**
|
|
63
|
-
> Some providers advertise model ids in a `provider__model` form. For example,
|
|
64
|
-
> [llmproxy](https://github.com/BillJr99/llmproxy) exposes ids like
|
|
65
|
-
> `openrouter__gpt-4` and virtual models such as `llmproxy__free` and
|
|
66
|
-
> `llmproxy__loadbalanced`. The extension can optionally rewrite the first `__`
|
|
67
|
-
> of each id to `/` (e.g. `openrouter__gpt-4` → `openrouter/gpt-4`,
|
|
68
|
-
> `llmproxy__free` → `llmproxy/free`) before registering with pi, so the ids
|
|
69
|
-
> display in the more familiar `provider/model` slash form. Upstreams that use
|
|
70
|
-
> the `__` convention canonicalize the slash form back to `__` on each request,
|
|
71
|
-
> so routing still works.
|
|
72
|
-
>
|
|
73
|
-
> This is a presentation-only convenience controlled by a per-provider config
|
|
74
|
-
> field (`rewriteDoubleUnderscore`, default **false**). It is enabled
|
|
75
|
-
> automatically for the llmproxy template purely for display consistency — other
|
|
76
|
-
> providers are unaffected, and you can turn it on or off freely. If you added a
|
|
77
|
-
> provider as a **Custom** endpoint and want the slash-form display, set
|
|
78
|
-
> `"rewriteDoubleUnderscore": true` on that provider in
|
|
79
|
-
> `~/.config/pi-openai-compat/config.json` (or re-run `/compat-login` and pick a
|
|
80
|
-
> template that enables it). Leaving it off keeps the original `__` ids.
|
|
81
|
-
|
|
82
62
|
> **Providers whose model catalog lives at a non-standard `/models` path (as of June 2026)**
|
|
83
63
|
> Some providers don't return models at `<base_url>/models`. The extension
|
|
84
64
|
> handles them in one of two ways:
|
|
@@ -353,9 +333,6 @@ The usual cause is a **scoped or restricted API key/account** — the catalog
|
|
|
353
333
|
endpoint advertises the full model list, but your credentials are only entitled
|
|
354
334
|
to a subset, so pi only surfaces the ones you can actually use. Check whether your
|
|
355
335
|
key is limited to specific models or a free tier on the provider's dashboard.
|
|
356
|
-
(This is unrelated to the `__` → `/` rewrite, which is a display-only convenience —
|
|
357
|
-
see the note in **Supported providers** above. Toggling `rewriteDoubleUnderscore`
|
|
358
|
-
only changes how ids are displayed, not how many appear.)
|
|
359
336
|
|
|
360
337
|
**Models appear in `/model` but requests fail**
|
|
361
338
|
Check `/compat-login` ran successfully (no error message).
|
package/index.ts
CHANGED
|
@@ -48,13 +48,6 @@ interface ProviderConfig {
|
|
|
48
48
|
// matches its template and can't be auto-migrated, so the notice is shown
|
|
49
49
|
// only once rather than on every session_start while the config stays stale.
|
|
50
50
|
staleNotified?: boolean;
|
|
51
|
-
// When true, rewrite the FIRST "__" of every model id to "/" before
|
|
52
|
-
// registering with pi, so ids from providers that use a "provider__model"
|
|
53
|
-
// convention (e.g. llmproxy) display in the more familiar "provider/model"
|
|
54
|
-
// slash form. This is a display-only convenience: such upstreams canonicalize
|
|
55
|
-
// the slash form back to "__" on each request, so requests still round-trip.
|
|
56
|
-
// Defaults false; the wizard turns it on only for the llmproxy template.
|
|
57
|
-
rewriteDoubleUnderscore?: boolean;
|
|
58
51
|
}
|
|
59
52
|
|
|
60
53
|
interface ExtensionConfig {
|
|
@@ -104,13 +97,6 @@ const TEMPLATES: Record<string, {
|
|
|
104
97
|
modelsIdField?: string;
|
|
105
98
|
/** Keep only models whose task.name matches this string (case-insensitive). */
|
|
106
99
|
modelsKeepTask?: string;
|
|
107
|
-
/**
|
|
108
|
-
* Rewrite the first "__" of each model id to "/" before registering with pi,
|
|
109
|
-
* for display compatibility — ids from "provider__model" upstreams (e.g.
|
|
110
|
-
* llmproxy) then show in the familiar "provider/model" slash form. Display-only;
|
|
111
|
-
* default false; set true where you want the slash-form presentation.
|
|
112
|
-
*/
|
|
113
|
-
rewriteDoubleUnderscore?: boolean;
|
|
114
100
|
}> = {
|
|
115
101
|
openrouter: {
|
|
116
102
|
displayName: "OpenRouter",
|
|
@@ -302,10 +288,6 @@ const TEMPLATES: Record<string, {
|
|
|
302
288
|
baseUrl: "http://localhost:8080/v1",
|
|
303
289
|
keyless: true,
|
|
304
290
|
promptUrl: true,
|
|
305
|
-
// llmproxy advertises "provider__model" ids (and virtuals like
|
|
306
|
-
// "llmproxy__free"). Rewrite the first "__" to "/" here so they display in
|
|
307
|
-
// the familiar slash form; llmproxy canonicalizes it back on requests.
|
|
308
|
-
rewriteDoubleUnderscore: true,
|
|
309
291
|
},
|
|
310
292
|
vercel: {
|
|
311
293
|
displayName: "Vercel AI Gateway",
|
|
@@ -553,21 +535,9 @@ async function fetchModels(
|
|
|
553
535
|
// Provider registration helpers
|
|
554
536
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
555
537
|
|
|
556
|
-
|
|
557
|
-
* Rewrite the FIRST "__" of a model id to "/". Only the first occurrence is
|
|
558
|
-
* touched: the provider/virtual segment that precedes it never contains "__" or
|
|
559
|
-
* "/", so this is the exact inverse of the slash→"__" canonicalization llmproxy
|
|
560
|
-
* applies on the request side, keeping ids round-trippable. Ids without "__" are
|
|
561
|
-
* returned unchanged.
|
|
562
|
-
*/
|
|
563
|
-
function rewriteFirstDoubleUnderscore(id: string): string {
|
|
564
|
-
const i = id.indexOf("__");
|
|
565
|
-
return i === -1 ? id : `${id.slice(0, i)}/${id.slice(i + 2)}`;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
function buildProviderModels(models: CachedModel[], rewriteDoubleUnderscore = false) {
|
|
538
|
+
function buildProviderModels(models: CachedModel[]) {
|
|
569
539
|
return models.map((m) => {
|
|
570
|
-
const id =
|
|
540
|
+
const id = m.id;
|
|
571
541
|
return {
|
|
572
542
|
id,
|
|
573
543
|
name: id,
|
|
@@ -585,16 +555,12 @@ function compatKey(key: string): string {
|
|
|
585
555
|
}
|
|
586
556
|
|
|
587
557
|
function registerProvider(pi: ExtensionAPI, key: string, p: ProviderConfig): void {
|
|
588
|
-
// Honor the persisted per-provider flag; fall back to the template default for
|
|
589
|
-
// this key so providers logged in before the flag existed (e.g. an existing
|
|
590
|
-
// llmproxy provider) still get the rewrite without a re-login.
|
|
591
|
-
const rewrite = p.rewriteDoubleUnderscore ?? TEMPLATES[key]?.rewriteDoubleUnderscore ?? false;
|
|
592
558
|
pi.registerProvider(compatKey(key), {
|
|
593
559
|
name: `compat/${key.replace(/_/g, "-")}`,
|
|
594
560
|
baseUrl: p.baseUrl,
|
|
595
561
|
apiKey: p.apiKey ?? (isLocalUrl(p.baseUrl) ? "local" : ""),
|
|
596
562
|
api: "openai-completions" as const,
|
|
597
|
-
models: buildProviderModels(p.cachedModels
|
|
563
|
+
models: buildProviderModels(p.cachedModels),
|
|
598
564
|
});
|
|
599
565
|
}
|
|
600
566
|
|
|
@@ -837,7 +803,6 @@ export default async function (pi: ExtensionAPI) {
|
|
|
837
803
|
modelsUrl,
|
|
838
804
|
modelsIdField: tpl.modelsIdField,
|
|
839
805
|
modelsKeepTask: tpl.modelsKeepTask,
|
|
840
|
-
rewriteDoubleUnderscore: tpl.rewriteDoubleUnderscore,
|
|
841
806
|
};
|
|
842
807
|
saveConfig(config);
|
|
843
808
|
registerProvider(pi, key, config.providers[key]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@billjr99/pi-openai-compat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "pi-coding-agent extension: OpenAI-compatible endpoint support (OpenRouter, NVIDIA NIM, Nous Portal, Ollama, custom)",
|
|
5
5
|
"author": "Bill Mongan <https://github.com/BillJr99>",
|
|
6
6
|
"license": "MIT",
|