okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221merge f-split-ui4 a7cd2b38e into f-split-int7c4b3d743

main
1.2 KiB19 linesraw
1/** What a saved tuning changes in the engine's start-up flags (GET /api/native/models/<id>/settings -> tuned.changed), as the Expert mode fields show it. */
2export interface TunedChange { flag: string; was: string | null; now: string | null }
3export interface TunedFields { kv?: string; lowRam?: 'auto' | 'resident' | 'mmap'; vramReserveMib?: number }
4
5export function tunedFields(changed: TunedChange[] | undefined | null): TunedFields {
6  const out: TunedFields = {};
7  for (const c of changed ?? []) {
8    if (c.flag === '--kv' && c.now) out.kv = c.now;
9    else if (c.flag === '--resident-experts') out.lowRam = c.now !== null ? 'resident' : c.was !== null ? 'auto' : out.lowRam;
10    else if (c.flag === '--mmap-experts') out.lowRam = c.now !== null ? 'mmap' : c.was !== null ? 'auto' : out.lowRam;
11    else if (c.flag === '--vram-reserve-mib' && c.now !== null && Number.isFinite(Number(c.now))) out.vramReserveMib = Number(c.now);
12  }
13  return out;
14}
15
16/** "--spec 6 (was 4)" for the list of what the tuning changed. */
17export function describeChange(c: TunedChange): { name: string; now: string; was: string | null } {
18  return { name: c.flag.replace(/^--/, '').replace(/-/g, ' '), now: c.now ?? '', was: c.was };
19}