@mcowger/pi-plexus 1.0.2 → 1.0.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/README.md +1 -1
- package/dist/extension.js +12 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -227,7 +227,7 @@ Models with a falsy `id` are skipped. Missing metadata falls back to safe defaul
|
|
|
227
227
|
|
|
228
228
|
## Adapter behavior
|
|
229
229
|
|
|
230
|
-
- **pi** refreshes on
|
|
230
|
+
- **pi** refreshes on startup, extension reload, and through `/plexus refresh`. It accepts either root URLs or URLs ending in `/v1` and normalizes them before calling Plexus.
|
|
231
231
|
- **OpenCode** seeds the provider from cache or a placeholder model during config loading, then performs live discovery through the `provider.models` hook. If Plexus is slow or unavailable, OpenCode uses the cache and lets the refresh continue in the background.
|
|
232
232
|
- Both adapters convert Plexus's per-token base and tier rates to the per-million-token units expected by their host.
|
|
233
233
|
|
package/dist/extension.js
CHANGED
|
@@ -46,6 +46,9 @@ function mapInputModalities(model) {
|
|
|
46
46
|
return result.length > 0 ? result : ["text"];
|
|
47
47
|
}
|
|
48
48
|
function isChatModel(model) {
|
|
49
|
+
const inputModalities = model.architecture?.input_modalities;
|
|
50
|
+
if (inputModalities !== undefined && !inputModalities.includes("text"))
|
|
51
|
+
return false;
|
|
49
52
|
const outputModalities = model.architecture?.output_modalities;
|
|
50
53
|
if (outputModalities !== undefined)
|
|
51
54
|
return outputModalities.includes("text");
|
|
@@ -467,6 +470,9 @@ function getPlexusModelBaseUrl(baseUrl, api) {
|
|
|
467
470
|
const apiBase = normalized.endsWith("/v1") ? normalized : `${normalized}/v1`;
|
|
468
471
|
return adjustBaseUrl(apiBase, api);
|
|
469
472
|
}
|
|
473
|
+
function shouldRefreshModels(reason) {
|
|
474
|
+
return reason === "startup" || reason === "reload";
|
|
475
|
+
}
|
|
470
476
|
var currentModels = [];
|
|
471
477
|
function plexusExtension(pi) {
|
|
472
478
|
const cached = readCachedModelsSync();
|
|
@@ -485,7 +491,11 @@ function plexusExtension(pi) {
|
|
|
485
491
|
oauth: createPlexusLoginProvider(pi)
|
|
486
492
|
});
|
|
487
493
|
currentModels = startupModels;
|
|
488
|
-
pi.on("session_start", async (
|
|
494
|
+
pi.on("session_start", async (event, ctx) => {
|
|
495
|
+
if (!shouldRefreshModels(event.reason)) {
|
|
496
|
+
log("session_start: skipping refresh", { reason: event.reason });
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
489
499
|
const apiKey = await ctx.modelRegistry.authStorage.getApiKey(PROVIDER_NAME) ?? getEnvApiKey();
|
|
490
500
|
const baseUrl = getBaseUrl();
|
|
491
501
|
log("session_start", { hasApiKey: !!apiKey, baseUrl });
|
|
@@ -605,6 +615,7 @@ async function trySetDefaultModel(pi, models) {
|
|
|
605
615
|
log("trySetDefaultModel", { defaultModelId, ok });
|
|
606
616
|
}
|
|
607
617
|
export {
|
|
618
|
+
shouldRefreshModels,
|
|
608
619
|
getPlexusModelBaseUrl,
|
|
609
620
|
plexusExtension as default
|
|
610
621
|
};
|