char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1/** 2* Model load progress helpers for the /models/sse surfaces 3* (selector row and chat message). 4*/ 5 6import { MODEL_LOAD_STAGE_LABELS , MODEL_LOAD_TAIL_SHARE } from '$lib/constants' ; 7 8/** 9* Human label for a model load stage. 10*/ 11export function modelLoadStageLabel ( stage :ApiModelLoadStage ) :string { 12return MODEL_LOAD_STAGE_LABELS [ stage ]; 13} 14 15/** 16* Overall load fraction (0.0 -> 1.0) across the declared stage plan. 17* text_model fills [0, 1 - tail], each later phase owns one tail slice. 18*/ 19export function modelLoadFraction ( progress :ModelLoadProgress | null ) :number { 20if ( ! progress ) return 0 ; 21 22// The server may emit a progress event before the stage plan is known, so 23// `stages` can be absent. Fall back to the raw value in that case. 24const { current, stages= [], value} = progress ; 25const tailCount = Math . max ( stages . length - 1 , 0 ); 26const textCeiling = 1 - tailCount * MODEL_LOAD_TAIL_SHARE ; 27const idx = stages . indexOf ( current ); 28 29if ( idx <= 0 ) { 30return value * textCeiling ; 31} 32 33return textCeiling + ( idx - 1 + value ) * MODEL_LOAD_TAIL_SHARE ; 34} 35 36/** 37* Single line describing load progress: active stage label and overall percent. 38* Returns null when there is no progress to show. 39*/ 40export function modelLoadProgressText ( progress :ModelLoadProgress | null ) :string | null { 41if ( ! progress ) return null ; 42 43const label = modelLoadStageLabel ( progress . current ); 44 45if ( ! label ) return null ; 46 47return ` ${ label } ${ Math . round ( modelLoadFraction ( progress ) * 100 )} %` ; 48}