Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 34x 34x 14x 13x 12x 24x 12x 12x 12x 13x 12x | import { SYSTEM_NODE_CONFIG } from "@/components/chat/ExecutionPipeline/nodeMeta";
import { StepUsage } from "@/objects/Cost";
/**
* How a step of the pipeline is named in "Where the tokens go". svc-ai
* labels every model call with what it was for (`metering.Step`, or a
* structured call's purpose — a system node's id or `retrieval.*`); system
* nodes are named as the execution pipeline names them (`nodeMeta`).
*/
const STEP_LABELS: Record<string, string> = {
respond: "Answer",
continuation: "Continuing a cut-off reply",
memory_summary: "Memory summary",
"memory.extract": "Memory · choosing what to keep",
route: "Choosing a branch",
"retrieval.query_planner": "Retrieval · planning queries",
"retrieval.reranker": "Retrieval · reranking",
};
const isSystem = (id: string | null): id is string =>
!!id && id in SYSTEM_NODE_CONFIG;
/** The step's name, and the node it ran in when that says more. */
export function stepLabel(row: StepUsage): { label: string; node: string | null } {
if (row.kind === "embedding") return { label: "Embeddings", node: null };
const named = (id: string | null, labels: Record<string, string> = {}) =>
id
? (labels[id] ?? (isSystem(id) ? SYSTEM_NODE_CONFIG[id].label : id))
: null;
const step = named(row.step, STEP_LABELS);
const node = named(row.node);
let label = step ?? node ?? "Not recorded";
if ((row.pass_index ?? 0) > 0) label += ` (revision ${row.pass_index})`;
return { label, node: node && node !== step ? node : null };
}
|