Project Files
dist / config.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.globalConfigSchematics = exports.embedConfigSchematics = exports.configSchematics = exports.placeholderModelValue = void 0;
exports.updateModelOptions = updateModelOptions;
exports.updateEmbedModelOptions = updateEmbedModelOptions;
exports.loadConfigSchematicsFromCache = loadConfigSchematicsFromCache;
const sdk_1 = require("@lmstudio/sdk");
const modelCache_1 = require("./modelCache");
exports.placeholderModelValue = "__refresh_shim_inventory__";
const placeholderOption = {
value: exports.placeholderModelValue,
displayName: "Refresh shim-hosted model inventory",
};
function normalizeModelOptions(models) {
const seen = new Set();
const options = [];
for (const model of models) {
if (!model?.id || seen.has(model.id))
continue;
seen.add(model.id);
options.push({ value: model.id, displayName: model.displayName });
}
return options;
}
function buildConfigSchematics(models, defaultModel) {
const options = normalizeModelOptions(models);
const allOptions = [placeholderOption, ...options];
const resolvedDefault = defaultModel && allOptions.some(option => option.value === defaultModel)
? defaultModel
: options[0]?.value ?? exports.placeholderModelValue;
return (0, sdk_1.createConfigSchematics)()
.field("model", "select", {
displayName: "Model",
subtitle: "Generator models exposed by the MemryX shim. These are selector-only entries for LM Studio's adapter UI.",
options: allOptions,
}, resolvedDefault)
.build();
}
function buildEmbedConfigSchematics(models, defaultModel) {
const options = normalizeModelOptions(models);
const allOptions = [placeholderOption, ...options];
const resolvedDefault = defaultModel && allOptions.some(option => option.value === defaultModel)
? defaultModel
: options[0]?.value ?? exports.placeholderModelValue;
return (0, sdk_1.createConfigSchematics)()
.field("embedModel", "select", {
displayName: "Embedding Model",
subtitle: "Embedding-capable models exposed by the MemryX shim. These stay separate from generator models so the embed lane remains visible.",
options: allOptions,
}, resolvedDefault)
.build();
}
exports.configSchematics = buildConfigSchematics([], "");
exports.embedConfigSchematics = buildEmbedConfigSchematics([], "");
function updateModelOptions(models, defaultModel) {
exports.configSchematics = buildConfigSchematics(models, defaultModel);
return exports.configSchematics;
}
function updateEmbedModelOptions(models, defaultModel) {
exports.embedConfigSchematics = buildEmbedConfigSchematics(models, defaultModel);
return exports.embedConfigSchematics;
}
function loadConfigSchematicsFromCache() {
const cachedState = (0, modelCache_1.readCachedState)();
const cachedLastSelected = cachedState.lastSelected && cachedState.lastSelected !== exports.placeholderModelValue
? cachedState.lastSelected
: undefined;
const cachedEmbedLastSelected = cachedState.lastSelectedEmbed && cachedState.lastSelectedEmbed !== exports.placeholderModelValue
? cachedState.lastSelectedEmbed
: undefined;
const selectedModel = cachedLastSelected
? cachedState.models.find(model => model.id === cachedLastSelected)
: undefined;
const selectedEmbedModel = cachedEmbedLastSelected
? cachedState.embedModels.find(model => model.id === cachedEmbedLastSelected)
: undefined;
const initialModels = selectedModel
? [selectedModel, ...cachedState.models.filter(model => model.id !== cachedLastSelected)]
: cachedState.models;
const initialEmbedModels = selectedEmbedModel
? [selectedEmbedModel, ...cachedState.embedModels.filter(model => model.id !== cachedEmbedLastSelected)]
: cachedState.embedModels;
updateEmbedModelOptions(initialEmbedModels, cachedEmbedLastSelected ?? "");
return updateModelOptions(initialModels, cachedLastSelected ?? "");
}
exports.globalConfigSchematics = (0, sdk_1.createConfigSchematics)()
.field("shimBaseUrl", "string", {
displayName: "Shim Base URL",
subtitle: "This plugin uses the MemryX shim authority (for example http://127.0.0.1:9000/v1).",
placeholder: "http://127.0.0.1:9000/v1",
}, "http://127.0.0.1:9000/v1")
.field("inventoryMode", "select", {
displayName: "Inventory Mode",
subtitle: "Health mode is the default; aggregate mode uses the full /v1/models endpoint.",
options: [
{ value: "health", displayName: "Health inventory (/v1/models?health=1)" },
{ value: "aggregate", displayName: "Aggregate inventory (/v1/models)" },
],
}, "health")
.build();
//# sourceMappingURL=config.js.map