pi-lilac-provider 1.8.2 → 1.9.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/index.ts +51 -2
- package/package.json +6 -3
package/index.ts
CHANGED
|
@@ -214,7 +214,7 @@ function parseModelOverrides(raw: unknown): Record<string, ModelOverride> | unde
|
|
|
214
214
|
if (o.thinkingLevelMap && typeof o.thinkingLevelMap === "object") {
|
|
215
215
|
const m: Record<string, string | null> = {};
|
|
216
216
|
for (const [k, v] of Object.entries(o.thinkingLevelMap as Record<string, unknown>)) {
|
|
217
|
-
if (v === null || typeof v === "string") m[k] = v;
|
|
217
|
+
if (v === null || typeof v === "string") m[k] = v as string | null;
|
|
218
218
|
}
|
|
219
219
|
if (Object.keys(m).length > 0) parsed.thinkingLevelMap = m as ThinkingLevelMap;
|
|
220
220
|
}
|
|
@@ -1228,7 +1228,56 @@ export default function (pi: ExtensionAPI) {
|
|
|
1228
1228
|
description: "Configure Lilac: flex discount threshold + preserved thinking per model",
|
|
1229
1229
|
async handler(_args, ctx) {
|
|
1230
1230
|
if (ctx.mode !== "tui") {
|
|
1231
|
-
|
|
1231
|
+
// GUI/RPC fallback: a select -> select flow. The custom SettingsList is
|
|
1232
|
+
// TUI-only. One setting per run; per-model preserved thinking is a
|
|
1233
|
+
// pick-model -> pick-value pair.
|
|
1234
|
+
if (!ctx.hasUI) {
|
|
1235
|
+
ctx.ui.notify("/lilac-settings requires a UI (TUI or GUI).", "error");
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
const currentFlex = getConfig().flexThreshold ?? null;
|
|
1239
|
+
const guiItems = [
|
|
1240
|
+
{ id: "flex", label: "Flex threshold", current: currentFlex == null ? "off" : String(currentFlex), values: ["off", "50", "75"] },
|
|
1241
|
+
{ id: "preserved-thinking", label: "Preserved thinking", current: "configure" },
|
|
1242
|
+
];
|
|
1243
|
+
const pick = await ctx.ui.select("Lilac settings — pick a setting", guiItems.map((i) => `${i.label}: ${i.current}`));
|
|
1244
|
+
if (pick === undefined) return;
|
|
1245
|
+
const item = guiItems.find((i) => pick.startsWith(`${i.label}:`));
|
|
1246
|
+
if (!item) return;
|
|
1247
|
+
if (item.id === "flex") {
|
|
1248
|
+
const v = await ctx.ui.select("Flex threshold", ["off", "50", "75"]);
|
|
1249
|
+
if (v === undefined) return;
|
|
1250
|
+
applyFlexThreshold(v === "off" ? null : Number(v), ctx);
|
|
1251
|
+
} else {
|
|
1252
|
+
const fresh = collectPreserveState();
|
|
1253
|
+
if (fresh.length === 0) { ctx.ui.notify("No models support preserved thinking.", "info"); return; }
|
|
1254
|
+
const modelPick = await ctx.ui.select("Preserved thinking — pick a model", fresh.map((e) => `${e.name}: ${e.preserved ? "Preserve Thinking" : "Clear Thinking"}`));
|
|
1255
|
+
if (modelPick === undefined) return;
|
|
1256
|
+
const entry = fresh.find((e) => modelPick.startsWith(`${e.name}:`));
|
|
1257
|
+
if (!entry) return;
|
|
1258
|
+
const v = await ctx.ui.select(entry.name, ["Preserve Thinking", "Clear Thinking"]);
|
|
1259
|
+
if (v === undefined) return;
|
|
1260
|
+
const preservedOn = v === "Preserve Thinking";
|
|
1261
|
+
const flagValue = entry.flag === "clear_thinking" ? !preservedOn : preservedOn;
|
|
1262
|
+
updateConfig((cfg) => {
|
|
1263
|
+
const overrides = cfg.modelOverrides ?? (cfg.modelOverrides = {});
|
|
1264
|
+
const ov = overrides[entry.id] ?? (overrides[entry.id] = {});
|
|
1265
|
+
const compat = ov.compat ?? (ov.compat = {});
|
|
1266
|
+
const kwargs = compat.chatTemplateKwargs ?? (compat.chatTemplateKwargs = {});
|
|
1267
|
+
kwargs[entry.flag] = flagValue;
|
|
1268
|
+
return cfg;
|
|
1269
|
+
});
|
|
1270
|
+
listModelsCache = null;
|
|
1271
|
+
pi.registerProvider("lilac", {
|
|
1272
|
+
baseUrl: BASE_URL,
|
|
1273
|
+
apiKey: "$LILAC_API_KEY",
|
|
1274
|
+
api: "openai-completions",
|
|
1275
|
+
models: applyDiscounts(getListModels(), latestDiscounts),
|
|
1276
|
+
});
|
|
1277
|
+
syncStatus(ctx);
|
|
1278
|
+
ctx.ui.notify(`Preserved thinking ${preservedOn ? "on" : "off"} for ${entry.name} — takes effect now.`, "info");
|
|
1279
|
+
}
|
|
1280
|
+
ctx.ui.notify("Run /lilac-settings again for more.", "info");
|
|
1232
1281
|
return;
|
|
1233
1282
|
}
|
|
1234
1283
|
const { SettingsList, Container } = await import("@earendil-works/pi-tui");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-lilac-provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Lilac provider extension for pi - Access Kimi K2.6, GLM 5.1, and Gemma 4 models through Lilac's OpenAI-compatible API on idle GPUs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
"@earendil-works/pi-coding-agent": ">=0.74.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@earendil-works/pi-coding-agent": "0.80.3"
|
|
32
|
+
"@earendil-works/pi-coding-agent": "0.80.3",
|
|
33
|
+
"typescript": "6.0.3",
|
|
34
|
+
"@types/node": "25.9.1",
|
|
35
|
+
"knip": "6.14.1"
|
|
33
36
|
},
|
|
34
37
|
"pi": {
|
|
35
38
|
"extensions": [
|
|
@@ -39,7 +42,7 @@
|
|
|
39
42
|
"scripts": {
|
|
40
43
|
"clean": "echo 'nothing to clean'",
|
|
41
44
|
"build": "echo 'nothing to build'",
|
|
42
|
-
"check": "
|
|
45
|
+
"check": "tsc --noEmit && knip --no-gitignore",
|
|
43
46
|
"test": "node scripts/test-discounts.ts && node scripts/test-preserved-thinking.ts && node scripts/test-model-overrides.ts && node scripts/test-flex.ts",
|
|
44
47
|
"test:discounts": "node scripts/test-discounts.ts",
|
|
45
48
|
"test:thinking": "node scripts/test-preserved-thinking.ts",
|