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