@xynogen/pix-models 0.1.3 → 0.1.5
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 +3 -1
- package/package.json +1 -1
- package/src/models.ts +68 -57
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Registers a `/models` slash command that replaces Pi's built-in `/model` selecto
|
|
|
12
12
|
pi install npm:@xynogen/pix-models
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
> Also included in [`@xynogen/pix-core`](https://
|
|
15
|
+
> Also included in [`@xynogen/pix-core`](https://www.npmjs.com/package/@xynogen/pix-core):
|
|
16
16
|
>
|
|
17
17
|
> ```bash
|
|
18
18
|
> pi install npm:@xynogen/pix-core
|
|
@@ -20,6 +20,8 @@ pi install npm:@xynogen/pix-models
|
|
|
20
20
|
|
|
21
21
|
## Full distro
|
|
22
22
|
|
|
23
|
+
Source: [github.com/xynogen/pix-mono](https://github.com/xynogen/pix-mono)
|
|
24
|
+
|
|
23
25
|
To install the complete pix suite (all packages + Pi itself):
|
|
24
26
|
|
|
25
27
|
```bash
|
package/package.json
CHANGED
package/src/models.ts
CHANGED
|
@@ -115,11 +115,14 @@ async function showEnhancedPicker(
|
|
|
115
115
|
m: (typeof available)[number];
|
|
116
116
|
dev: ReturnType<typeof lookupModelsDev>;
|
|
117
117
|
bench: ReturnType<typeof lookupBenchmark>;
|
|
118
|
+
// Rank among the user's *available* models, not the global catalog.
|
|
119
|
+
localRank: number | null;
|
|
118
120
|
};
|
|
119
121
|
const rows: Row[] = available.map((m) => ({
|
|
120
122
|
m,
|
|
121
123
|
dev: lookupModelsDev(m.provider, m.id),
|
|
122
|
-
bench: lookupBenchmark(m.
|
|
124
|
+
bench: lookupBenchmark(m.id),
|
|
125
|
+
localRank: null,
|
|
123
126
|
}));
|
|
124
127
|
|
|
125
128
|
// Sort: by score desc (highest first), unscored last alphabetical
|
|
@@ -130,6 +133,10 @@ async function showEnhancedPicker(
|
|
|
130
133
|
return (a.m.name ?? a.m.id).localeCompare(b.m.name ?? b.m.id);
|
|
131
134
|
});
|
|
132
135
|
|
|
136
|
+
// Local rank = position among scored available models (best pickable = #1).
|
|
137
|
+
let localRank = 0;
|
|
138
|
+
for (const r of rows) if (r.bench) r.localRank = ++localRank;
|
|
139
|
+
|
|
133
140
|
// Show all models (no deduplication)
|
|
134
141
|
const dedupedRows = rows;
|
|
135
142
|
|
|
@@ -142,7 +149,9 @@ async function showEnhancedPicker(
|
|
|
142
149
|
|
|
143
150
|
// Find max rank width across all benchmarked rows for # padding
|
|
144
151
|
const maxRankWidth = Math.max(
|
|
145
|
-
...dedupedRows.map((r) =>
|
|
152
|
+
...dedupedRows.map((r) =>
|
|
153
|
+
r.localRank ? String(r.localRank).length : 0,
|
|
154
|
+
),
|
|
146
155
|
1,
|
|
147
156
|
);
|
|
148
157
|
|
|
@@ -152,64 +161,66 @@ async function showEnhancedPicker(
|
|
|
152
161
|
|
|
153
162
|
// Track rank per item value so fuzzy results can prioritize ranked models.
|
|
154
163
|
const rankByValue = new Map<string, number>();
|
|
155
|
-
for (const { m,
|
|
156
|
-
if (
|
|
164
|
+
for (const { m, localRank } of dedupedRows) {
|
|
165
|
+
if (localRank) rankByValue.set(`${m.provider}/${m.id}`, localRank);
|
|
157
166
|
}
|
|
158
167
|
|
|
159
|
-
const items: SelectItem[] = dedupedRows.map(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// Display model id only; m.provider is routing provider, not part of id.
|
|
173
|
-
const idColored = theme.fg(accent, m.id);
|
|
174
|
-
const label = `${marker} ${rankPrefix} ${idColored}`;
|
|
175
|
-
|
|
176
|
-
// Description: ctx · cost · score stars
|
|
177
|
-
// Colors: ctx muted · cost success (free muted) · score+stars warning
|
|
178
|
-
const ctxRaw = fmtCtx(dev?.limit?.context ?? 0);
|
|
179
|
-
const ctxStr = mute(ctxRaw.padStart(4));
|
|
180
|
-
const rawCost = fmtCost(dev);
|
|
181
|
-
let costSeg: string;
|
|
182
|
-
if (rawCost === "—") {
|
|
183
|
-
costSeg = theme.fg("dim", "—".padEnd(10));
|
|
184
|
-
} else if (rawCost === "free") {
|
|
185
|
-
costSeg = mute("free".padEnd(10));
|
|
186
|
-
} else {
|
|
187
|
-
costSeg = theme.fg("success", rawCost.padEnd(10));
|
|
188
|
-
}
|
|
189
|
-
let benchSeg = "";
|
|
190
|
-
if (bench) {
|
|
191
|
-
const score = bench.overallScore ?? "?";
|
|
192
|
-
const s = bench.overallScore;
|
|
193
|
-
let filled = 1;
|
|
194
|
-
if (typeof s === "number") {
|
|
195
|
-
if (s >= 90) filled = 5;
|
|
196
|
-
else if (s >= 80) filled = 4;
|
|
197
|
-
else if (s >= 70) filled = 3;
|
|
198
|
-
else if (s >= 50) filled = 2;
|
|
168
|
+
const items: SelectItem[] = dedupedRows.map(
|
|
169
|
+
({ m, dev, bench, localRank }) => {
|
|
170
|
+
const isCurrent =
|
|
171
|
+
current && m.provider === current.provider && m.id === current.id;
|
|
172
|
+
|
|
173
|
+
// Label: marker + muted '#' + bright rank + accent-colored model name
|
|
174
|
+
const marker = isCurrent ? theme.fg(accent, "▶") : " ";
|
|
175
|
+
let rankPrefix: string;
|
|
176
|
+
if (localRank) {
|
|
177
|
+
const rankStr = String(localRank).padEnd(maxRankWidth);
|
|
178
|
+
rankPrefix = mute("#") + theme.fg("warning", rankStr);
|
|
179
|
+
} else {
|
|
180
|
+
rankPrefix = " ".repeat(maxRankWidth + 1);
|
|
199
181
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
182
|
+
// Display model id only; m.provider is routing provider, not part of id.
|
|
183
|
+
const idColored = theme.fg(accent, m.id);
|
|
184
|
+
const label = `${marker} ${rankPrefix} ${idColored}`;
|
|
185
|
+
|
|
186
|
+
// Description: ctx · cost · score stars
|
|
187
|
+
// Colors: ctx muted · cost success (free muted) · score+stars warning
|
|
188
|
+
const ctxRaw = fmtCtx(dev?.limit?.context ?? 0);
|
|
189
|
+
const ctxStr = mute(ctxRaw.padStart(4));
|
|
190
|
+
const rawCost = fmtCost(dev);
|
|
191
|
+
let costSeg: string;
|
|
192
|
+
if (rawCost === "—") {
|
|
193
|
+
costSeg = theme.fg("dim", "—".padEnd(10));
|
|
194
|
+
} else if (rawCost === "free") {
|
|
195
|
+
costSeg = mute("free".padEnd(10));
|
|
196
|
+
} else {
|
|
197
|
+
costSeg = theme.fg("success", rawCost.padEnd(10));
|
|
198
|
+
}
|
|
199
|
+
let benchSeg = "";
|
|
200
|
+
if (bench) {
|
|
201
|
+
const score = bench.overallScore ?? "?";
|
|
202
|
+
const s = bench.overallScore;
|
|
203
|
+
let filled = 1;
|
|
204
|
+
if (typeof s === "number") {
|
|
205
|
+
if (s >= 90) filled = 5;
|
|
206
|
+
else if (s >= 80) filled = 4;
|
|
207
|
+
else if (s >= 70) filled = 3;
|
|
208
|
+
else if (s >= 50) filled = 2;
|
|
209
|
+
}
|
|
210
|
+
const starBar =
|
|
211
|
+
theme.fg("warning", "★".repeat(filled)) +
|
|
212
|
+
mute("☆".repeat(5 - filled));
|
|
213
|
+
benchSeg = `⚡${theme.fg("warning", String(score))} ${starBar}`;
|
|
214
|
+
}
|
|
215
|
+
const desc = [ctxStr, costSeg, benchSeg].filter(Boolean).join(sep);
|
|
206
216
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
return {
|
|
218
|
+
value: `${m.provider}/${m.id}`,
|
|
219
|
+
label,
|
|
220
|
+
description: desc,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
);
|
|
213
224
|
|
|
214
225
|
const currentIdx = current
|
|
215
226
|
? items.findIndex(
|
|
@@ -225,7 +236,7 @@ async function showEnhancedPicker(
|
|
|
225
236
|
new Text(
|
|
226
237
|
theme.fg(
|
|
227
238
|
"dim",
|
|
228
|
-
"context
|
|
239
|
+
"context · pricing · coding rank & score from modelgrep.com",
|
|
229
240
|
),
|
|
230
241
|
),
|
|
231
242
|
);
|