@mcowger/pi-plexus 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/extension.js +19 -4
  2. package/package.json +1 -1
package/dist/extension.js CHANGED
@@ -1,6 +1,7 @@
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;
4
5
  var API_DIALECT_MAP = {
5
6
  chat_completions: "openai-completions",
6
7
  "openai-completions": "openai-completions",
@@ -44,6 +45,15 @@ function mapInputModalities(model) {
44
45
  }
45
46
  return result.length > 0 ? result : ["text"];
46
47
  }
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
+ }
47
57
  function inferReasoning(model) {
48
58
  const params = model.supported_parameters;
49
59
  if (!params)
@@ -116,7 +126,7 @@ function convertToDescriptor(raw, baseUrl) {
116
126
  function convertDescriptors(models, baseUrl) {
117
127
  const result = [];
118
128
  for (const m of models) {
119
- if (!m.id)
129
+ if (!m.id || !isChatModel(m))
120
130
  continue;
121
131
  result.push(convertToDescriptor(m, baseUrl));
122
132
  }
@@ -455,11 +465,16 @@ function descriptorToPiModel(descriptor) {
455
465
  var PROVIDER_NAME = "plexus";
456
466
  var PROVIDER_API_KEY_TEMPLATE = "${PLEXUS_API_KEY}";
457
467
  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
+ }
458
473
  var currentModels = [];
459
474
  function plexusExtension(pi) {
460
475
  const cached = readCachedModelsSync();
461
476
  const startupBaseUrl = getBaseUrl() ?? "http://localhost/v1";
462
- const startupModels = cached?.models.map(descriptorToPiModel) ?? [];
477
+ const startupModels = cached?.models.filter(isChatModel).map(descriptorToPiModel) ?? [];
463
478
  log("startup", {
464
479
  cachedModelCount: startupModels.length,
465
480
  startupBaseUrl
@@ -532,8 +547,7 @@ function createPlexusLoginProvider(pi) {
532
547
  const baseUrl = credentials.plexusBaseUrl;
533
548
  if (!baseUrl)
534
549
  return models;
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);
550
+ return models.map((model) => model.provider === PROVIDER_NAME ? { ...model, baseUrl: getPlexusModelBaseUrl(baseUrl, model.api) } : model);
537
551
  }
538
552
  };
539
553
  }
@@ -594,5 +608,6 @@ async function trySetDefaultModel(pi, models) {
594
608
  log("trySetDefaultModel", { defaultModelId, ok });
595
609
  }
596
610
  export {
611
+ getPlexusModelBaseUrl,
597
612
  plexusExtension as default
598
613
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcowger/pi-plexus",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Plexus AI proxy plugin for the pi coding agent",
5
5
  "type": "module",
6
6
  "files": [