All files / src/utils model-show-rows.ts

100% Statements 8/8
100% Branches 6/6
100% Functions 1/1
100% Lines 6/6

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                        46x 46x 46x 46x 3x 46x    
import type { ModelShowResponse } from "../types";
import { MESSAGES } from "../locales/en";
 
export interface ModelShowRow {
    label: string;
    value: string;
}
 
/** The labelled rows a /api/models/show answer yields, in a fixed order.
 *  `chat_template` and `parameters` are multi-line blobs and `file_type` is a raw GGUF
 *  code, so none of the three gets a row. */
export function modelShowRows(info: ModelShowResponse): ModelShowRow[] {
    const rows: ModelShowRow[] = [];
    if (info.architecture) rows.push({ label: MESSAGES.LABEL_STATUS_ARCHITECTURE, value: info.architecture });
    if (info.context_length) rows.push({ label: MESSAGES.LABEL_STATUS_CONTEXT_LENGTH, value: info.context_length });
    if (info.embedding_length)
        rows.push({ label: MESSAGES.LABEL_STATUS_EMBEDDING_LENGTH, value: info.embedding_length });
    return rows;
}