CLI: show model cost in models list table
This commit is contained in:
parent
6c02b52358
commit
dfc5e58a0f
@ -8,7 +8,14 @@ export type ModelCatalogEntry = {
|
|||||||
provider: string;
|
provider: string;
|
||||||
contextWindow?: number;
|
contextWindow?: number;
|
||||||
reasoning?: boolean;
|
reasoning?: boolean;
|
||||||
|
confidentialCompute?: boolean;
|
||||||
input?: Array<"text" | "image">;
|
input?: Array<"text" | "image">;
|
||||||
|
cost?: {
|
||||||
|
input: number;
|
||||||
|
output: number;
|
||||||
|
cacheRead: number;
|
||||||
|
cacheWrite: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type DiscoveredModel = {
|
type DiscoveredModel = {
|
||||||
@ -18,6 +25,12 @@ type DiscoveredModel = {
|
|||||||
contextWindow?: number;
|
contextWindow?: number;
|
||||||
reasoning?: boolean;
|
reasoning?: boolean;
|
||||||
input?: Array<"text" | "image">;
|
input?: Array<"text" | "image">;
|
||||||
|
cost?: {
|
||||||
|
input: number;
|
||||||
|
output: number;
|
||||||
|
cacheRead: number;
|
||||||
|
cacheWrite: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type PiSdkModule = typeof import("@mariozechner/pi-coding-agent");
|
type PiSdkModule = typeof import("@mariozechner/pi-coding-agent");
|
||||||
@ -82,10 +95,24 @@ export async function loadModelCatalog(params?: {
|
|||||||
? entry.contextWindow
|
? entry.contextWindow
|
||||||
: undefined;
|
: undefined;
|
||||||
const reasoning = typeof entry?.reasoning === "boolean" ? entry.reasoning : undefined;
|
const reasoning = typeof entry?.reasoning === "boolean" ? entry.reasoning : undefined;
|
||||||
|
const confidentialCompute =
|
||||||
|
typeof (entry as any)?.confidentialCompute === "boolean"
|
||||||
|
? (entry as any).confidentialCompute
|
||||||
|
: undefined;
|
||||||
const input = Array.isArray(entry?.input)
|
const input = Array.isArray(entry?.input)
|
||||||
? (entry.input as Array<"text" | "image">)
|
? (entry.input as Array<"text" | "image">)
|
||||||
: undefined;
|
: undefined;
|
||||||
models.push({ id, name, provider, contextWindow, reasoning, input });
|
const cost = entry?.cost ? { ...entry.cost } : undefined;
|
||||||
|
models.push({
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
provider,
|
||||||
|
contextWindow,
|
||||||
|
reasoning,
|
||||||
|
confidentialCompute,
|
||||||
|
input,
|
||||||
|
cost,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (models.length === 0) {
|
if (models.length === 0) {
|
||||||
|
|||||||
@ -94,6 +94,12 @@ export function toModelRow(params: {
|
|||||||
contextWindow: model.contextWindow ?? null,
|
contextWindow: model.contextWindow ?? null,
|
||||||
local,
|
local,
|
||||||
available,
|
available,
|
||||||
|
cost: (model as any).cost
|
||||||
|
? {
|
||||||
|
input: (model as any).cost.input,
|
||||||
|
output: (model as any).cost.output,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
tags: Array.from(mergedTags),
|
tags: Array.from(mergedTags),
|
||||||
missing: false,
|
missing: false,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,6 +9,7 @@ const INPUT_PAD = 10;
|
|||||||
const CTX_PAD = 8;
|
const CTX_PAD = 8;
|
||||||
const LOCAL_PAD = 5;
|
const LOCAL_PAD = 5;
|
||||||
const AUTH_PAD = 5;
|
const AUTH_PAD = 5;
|
||||||
|
const COST_PAD = 12;
|
||||||
|
|
||||||
export function printModelTable(
|
export function printModelTable(
|
||||||
rows: ModelRow[],
|
rows: ModelRow[],
|
||||||
@ -41,6 +42,7 @@ export function printModelTable(
|
|||||||
pad("Ctx", CTX_PAD),
|
pad("Ctx", CTX_PAD),
|
||||||
pad("Local", LOCAL_PAD),
|
pad("Local", LOCAL_PAD),
|
||||||
pad("Auth", AUTH_PAD),
|
pad("Auth", AUTH_PAD),
|
||||||
|
pad("Cost (In/Out)", COST_PAD),
|
||||||
"Tags",
|
"Tags",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
runtime.log(rich ? theme.heading(header) : header);
|
runtime.log(rich ? theme.heading(header) : header);
|
||||||
@ -53,6 +55,8 @@ export function printModelTable(
|
|||||||
const localLabel = pad(localText, LOCAL_PAD);
|
const localLabel = pad(localText, LOCAL_PAD);
|
||||||
const authText = row.available === null ? "-" : row.available ? "yes" : "no";
|
const authText = row.available === null ? "-" : row.available ? "yes" : "no";
|
||||||
const authLabel = pad(authText, AUTH_PAD);
|
const authLabel = pad(authText, AUTH_PAD);
|
||||||
|
const costText = row.cost ? `${row.cost.input}/${row.cost.output}` : "-";
|
||||||
|
const costLabel = pad(costText, COST_PAD);
|
||||||
const tagsLabel =
|
const tagsLabel =
|
||||||
row.tags.length > 0
|
row.tags.length > 0
|
||||||
? rich
|
? rich
|
||||||
@ -82,6 +86,7 @@ export function printModelTable(
|
|||||||
ctxLabel,
|
ctxLabel,
|
||||||
coloredLocal,
|
coloredLocal,
|
||||||
coloredAuth,
|
coloredAuth,
|
||||||
|
costLabel,
|
||||||
tagsLabel,
|
tagsLabel,
|
||||||
].join(" ");
|
].join(" ");
|
||||||
runtime.log(line);
|
runtime.log(line);
|
||||||
|
|||||||
@ -12,6 +12,10 @@ export type ModelRow = {
|
|||||||
contextWindow: number | null;
|
contextWindow: number | null;
|
||||||
local: boolean | null;
|
local: boolean | null;
|
||||||
available: boolean | null;
|
available: boolean | null;
|
||||||
|
cost?: {
|
||||||
|
input: number;
|
||||||
|
output: number;
|
||||||
|
};
|
||||||
tags: string[];
|
tags: string[];
|
||||||
missing: boolean;
|
missing: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user