docs: polish package metadata and pricing display
This commit is contained in:
@@ -15,6 +15,7 @@ Interactive model selector for [pi](https://pi.dev/) with a provider-focused ter
|
||||
- Highlights the currently selected row
|
||||
- Marks current active model with `*`
|
||||
- Marks reasoning-capable models with `R`
|
||||
- Displays prices as `$input/$output · context`
|
||||
- Avoids overriding pi's built-in `/model` command
|
||||
|
||||
## UI preview
|
||||
@@ -42,6 +43,12 @@ Interactive model selector for [pi](https://pi.dev/) with a provider-focused ter
|
||||
pi install git:github.com/sakuradairong/pi-model-selector
|
||||
```
|
||||
|
||||
For a pinned install, use a release tag:
|
||||
|
||||
```bash
|
||||
pi install git:github.com/sakuradairong/pi-model-selector@v0.1.0
|
||||
```
|
||||
|
||||
Then restart pi, or run:
|
||||
|
||||
```text
|
||||
|
||||
10
package.json
10
package.json
@@ -1,8 +1,16 @@
|
||||
{
|
||||
"name": "pi-model-selector",
|
||||
"version": "0.1.0",
|
||||
"description": "Interactive provider-tabbed model selector extension for pi.",
|
||||
"description": "Interactive provider-focused model selector extension for pi.",
|
||||
"type": "module",
|
||||
"homepage": "https://github.com/sakuradairong/pi-model-selector#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sakuradairong/pi-model-selector.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sakuradairong/pi-model-selector/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"pi-package",
|
||||
"pi",
|
||||
|
||||
30
src/index.ts
30
src/index.ts
@@ -176,25 +176,21 @@ function buildProviderList(ctx: ExtensionContext): Provider[] {
|
||||
|
||||
function buildCostLabel(model: Model<Api>): string {
|
||||
const c = model.cost;
|
||||
if (!c) return "free";
|
||||
const ctxLabel = model.contextWindow ? formatContextWindow(model.contextWindow) : "";
|
||||
if (!c) return ctxLabel ? `free · ${ctxLabel}` : "free";
|
||||
|
||||
const inputCost = c.input > 0 ? `$${c.input}` : "free";
|
||||
const outputCost = c.output > 0 ? `$${c.output}` : "free";
|
||||
|
||||
const ctxWin = model.contextWindow;
|
||||
const ctxLabel = ctxWin ? formatContextWindow(ctxWin) : "";
|
||||
|
||||
if (inputCost === "free" && outputCost === "free") {
|
||||
return ctxLabel || "free";
|
||||
}
|
||||
|
||||
if (inputCost === outputCost) {
|
||||
return ctxLabel ? `$${c.input}/${ctxLabel}` : `$${c.input}`;
|
||||
}
|
||||
|
||||
return ctxLabel
|
||||
? `${inputCost}/${outputCost} · ${ctxLabel}`
|
||||
const inputCost = formatPrice(c.input);
|
||||
const outputCost = formatPrice(c.output);
|
||||
const priceLabel = inputCost === "free" && outputCost === "free"
|
||||
? "free"
|
||||
: `${inputCost}/${outputCost}`;
|
||||
|
||||
return ctxLabel ? `${priceLabel} · ${ctxLabel}` : priceLabel;
|
||||
}
|
||||
|
||||
function formatPrice(value: number): string {
|
||||
if (!Number.isFinite(value) || value <= 0) return "free";
|
||||
return `$${Number.isInteger(value) ? value : value.toFixed(3).replace(/0+$/, "").replace(/\.$/, "")}`;
|
||||
}
|
||||
|
||||
function modelKey(model: Model<Api>): string {
|
||||
|
||||
Reference in New Issue
Block a user