okami.mom/strata

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

Niko1221Merge f-split-fb4 (201d674e9) into f-split-int: cloudflared discovery, settings file, Gyro minimum engine, two models on two GPUs261145baa

main
2.0 KiB35 linesraw
1/**
2 * Does the installed engine read a model's files? The catalog (tools/strata_mcp.py, from setup.py's MODELS) names the first engine
3 * that does (`engine_min`, e.g. Gyro: 0.1.45.1, because its expert files are native_experts v5 and the released 0.1.45 stops at v4).
4 * An older engine would start the download and then fail on the files, so the app says "needs a newer engine" first.
5 */
6export function parseEngineVersion(value) {
7  const m = /^\s*v?(\d+(?:\.\d+){0,3})/.exec(String(value ?? ''));
8  return m ? m[1].split('.').map(Number) : null;
9}
10
11/** True when `installed` is known and older than `minimum`. An engine built from this checkout ('local') or one whose version cannot be read is never called too old. */
12export function engineTooOld(installed, minimum, source = null) {
13  if (!minimum || source === 'local') return false;
14  const have = parseEngineVersion(installed), need = parseEngineVersion(minimum);
15  if (!have || !need) return false;
16  for (let i = 0; i < 4; i++) {
17    const a = have[i] ?? 0, b = need[i] ?? 0;
18    if (a !== b) return a < b;
19  }
20  return false;
21}
22
23/** The catalog with `needsNewerEngine` on every size the installed engine cannot read. */
24export function markEngine(catalog, engine) {
25  if (!catalog || !Array.isArray(catalog.families)) return catalog;
26  const version = engine?.version ?? null, source = engine?.source ?? null;
27  return { ...catalog, families: catalog.families.map(f => ({ ...f, sizes: (f.sizes ?? []).map(s => ({ ...s, needsNewerEngine: engineTooOld(version, s.engine_min, source) })) })) };
28}
29
30/** The plain sentence for a refused install or load, or null when the engine is new enough. */
31export function engineRefusal(catalog, modelId, engine) {
32  const size = catalog?.families?.flatMap(f => f.sizes ?? []).find(s => s.id === modelId);
33  if (!size?.needsNewerEngine) return null;
34  return `This model needs a newer engine: ${size.model} needs engine ${size.engine_min} or newer, and this one is ${engine?.version}. Update the engine in Settings, then try again.`;
35}