@mcowger/pi-plexus 1.0.3 → 1.1.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/README.md +2 -0
- package/dist/extension.js +6 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -229,6 +229,8 @@ Models with a falsy `id` are skipped. Missing metadata falls back to safe defaul
|
|
|
229
229
|
|
|
230
230
|
- **pi** refreshes on session start 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
|
+
- OpenCode models retain their upstream model ID, SDK dialect, release date, and reasoning metadata so OpenCode can generate its native GPT, Claude, Gemini, and OpenAI-compatible variants and apply its current request transforms. DeepSeek models also preserve `reasoning_content` across tool-call turns.
|
|
233
|
+
- OpenCode uses a 250K-token context window when Plexus supplies no context metadata; its output fallback remains 20% of that window.
|
|
232
234
|
- Both adapters convert Plexus's per-token base and tier rates to the per-million-token units expected by their host.
|
|
233
235
|
|
|
234
236
|
## Development
|
package/dist/extension.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// ../plexus-models/src/convert.ts
|
|
3
3
|
var REASONING_PARAMS = new Set(["reasoning", "include_reasoning", "reasoning_effort"]);
|
|
4
|
-
var NON_CHAT_ID_PATTERN = /embedding|embed|tts|whisper|image-[0-9]|image\b.*gen|diffusion|dall-e|stable-diff|sdxl|dream/i;
|
|
5
4
|
var API_DIALECT_MAP = {
|
|
6
5
|
chat_completions: "openai-completions",
|
|
7
6
|
"openai-completions": "openai-completions",
|
|
@@ -45,15 +44,6 @@ function mapInputModalities(model) {
|
|
|
45
44
|
}
|
|
46
45
|
return result.length > 0 ? result : ["text"];
|
|
47
46
|
}
|
|
48
|
-
function isChatModel(model) {
|
|
49
|
-
const inputModalities = model.architecture?.input_modalities;
|
|
50
|
-
if (inputModalities !== undefined && !inputModalities.includes("text"))
|
|
51
|
-
return false;
|
|
52
|
-
const outputModalities = model.architecture?.output_modalities;
|
|
53
|
-
if (outputModalities !== undefined)
|
|
54
|
-
return outputModalities.includes("text");
|
|
55
|
-
return !NON_CHAT_ID_PATTERN.test(model.id);
|
|
56
|
-
}
|
|
57
47
|
function inferReasoning(model) {
|
|
58
48
|
const params = model.supported_parameters;
|
|
59
49
|
if (!params)
|
|
@@ -126,7 +116,7 @@ function convertToDescriptor(raw, baseUrl) {
|
|
|
126
116
|
function convertDescriptors(models, baseUrl) {
|
|
127
117
|
const result = [];
|
|
128
118
|
for (const m of models) {
|
|
129
|
-
if (!m.id
|
|
119
|
+
if (!m.id)
|
|
130
120
|
continue;
|
|
131
121
|
result.push(convertToDescriptor(m, baseUrl));
|
|
132
122
|
}
|
|
@@ -409,12 +399,12 @@ async function writeLogLine(message, data) {
|
|
|
409
399
|
}
|
|
410
400
|
|
|
411
401
|
// src/mapper.ts
|
|
412
|
-
import {
|
|
402
|
+
import { getBuiltinModel } from "@earendil-works/pi-ai/providers/all";
|
|
413
403
|
function descriptorToPiModel(descriptor) {
|
|
414
404
|
let builtinModel;
|
|
415
405
|
if (descriptor.piProvider && descriptor.piModel) {
|
|
416
406
|
try {
|
|
417
|
-
builtinModel =
|
|
407
|
+
builtinModel = getBuiltinModel(descriptor.piProvider, descriptor.piModel);
|
|
418
408
|
} catch {
|
|
419
409
|
builtinModel = undefined;
|
|
420
410
|
}
|
|
@@ -465,16 +455,11 @@ function descriptorToPiModel(descriptor) {
|
|
|
465
455
|
var PROVIDER_NAME = "plexus";
|
|
466
456
|
var PROVIDER_API_KEY_TEMPLATE = "${PLEXUS_API_KEY}";
|
|
467
457
|
var PLEXUS_CREDENTIAL_EXPIRES_AT = 253402300799000;
|
|
468
|
-
function getPlexusModelBaseUrl(baseUrl, api) {
|
|
469
|
-
const normalized = baseUrl.trim().replace(/\/+$/, "");
|
|
470
|
-
const apiBase = normalized.endsWith("/v1") ? normalized : `${normalized}/v1`;
|
|
471
|
-
return adjustBaseUrl(apiBase, api);
|
|
472
|
-
}
|
|
473
458
|
var currentModels = [];
|
|
474
459
|
function plexusExtension(pi) {
|
|
475
460
|
const cached = readCachedModelsSync();
|
|
476
461
|
const startupBaseUrl = getBaseUrl() ?? "http://localhost/v1";
|
|
477
|
-
const startupModels = cached?.models.
|
|
462
|
+
const startupModels = cached?.models.map(descriptorToPiModel) ?? [];
|
|
478
463
|
log("startup", {
|
|
479
464
|
cachedModelCount: startupModels.length,
|
|
480
465
|
startupBaseUrl
|
|
@@ -547,7 +532,8 @@ function createPlexusLoginProvider(pi) {
|
|
|
547
532
|
const baseUrl = credentials.plexusBaseUrl;
|
|
548
533
|
if (!baseUrl)
|
|
549
534
|
return models;
|
|
550
|
-
|
|
535
|
+
const apiBase = baseUrl.trim().replace(/\/+$/, "").endsWith("/v1") ? baseUrl.trim().replace(/\/+$/, "") : `${baseUrl.trim().replace(/\/+$/, "")}/v1`;
|
|
536
|
+
return models.map((model) => model.provider === PROVIDER_NAME ? { ...model, baseUrl: apiBase } : model);
|
|
551
537
|
}
|
|
552
538
|
};
|
|
553
539
|
}
|
|
@@ -608,6 +594,5 @@ async function trySetDefaultModel(pi, models) {
|
|
|
608
594
|
log("trySetDefaultModel", { defaultModelId, ok });
|
|
609
595
|
}
|
|
610
596
|
export {
|
|
611
|
-
getPlexusModelBaseUrl,
|
|
612
597
|
plexusExtension as default
|
|
613
598
|
};
|