Ship Assistent 0.14.1: Exact generate params and cheap park/warm.

Client always merges Exact turbo|raw steps/cfg/sigma before Generate so sparse LLM omissions and leftover SD 20/7 cannot stick; Ollama park/warm skip no-op /api/ps round-trips when the chat model is already unloaded or resident.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-23 06:50:08 +03:00
co-authored by Cursor
parent 9d2cbca8f2
commit 5f33130381
17 changed files with 1005 additions and 50 deletions
+108
View File
@@ -0,0 +1,108 @@
/**
* Krea turbo/raw profile detection + Exact param alignment helpers (pure).
* Prevents labeling ambiguous checkpoints as turbo while Swarm still has SD-like 20/7.
*/
export function numClose(a, b, eps = 0.051) {
const x = Number(a);
const y = Number(b);
if (!Number.isFinite(x) || !Number.isFinite(y)) {
return false;
}
return Math.abs(x - y) <= eps;
}
/**
* Detect turbo|raw from checkpoint name/title.
* Names without turbo/raw (e.g. realismByStableYogi) must NOT invent "turbo".
* Note: INT8Turbo has no word-boundary before "turbo" — use substring match.
*/
export function detectKreaProfileName(modelBlob, exactProfile) {
const blob = String(modelBlob || '').toLowerCase();
const hasTurbo = /turbo/.test(blob);
const hasRaw = /\braw\b|_raw\b|-raw\b|\/raw\b/.test(blob);
if (hasTurbo) {
return 'turbo';
}
if (hasRaw) {
return 'raw';
}
// Unlabeled ckpt — Exact generation.profile alone must not invent turbo.
void exactProfile;
return 'raw';
}
/** Profile-only defaults (no session overlay). */
export function profileParamDefaults(profiles, profileName, generation = {}) {
const profile = String(profileName || 'raw');
const fromProfile = profiles && typeof profiles[profile] === 'object' ? profiles[profile] : {};
const gen = generation && typeof generation === 'object' ? generation : {};
return {
profile,
steps: fromProfile.steps ?? gen.steps ?? null,
cfg: fromProfile.cfg ?? gen.cfg ?? null,
sigma_shift: fromProfile.sigma_shift ?? gen.sigma_shift ?? null,
};
}
/**
* Whether live Swarm numbers already match the Exact profile (steps/cfg/σ).
*/
export function liveMatchesExactProfile(live, defaults) {
if (!defaults || defaults.steps == null || defaults.cfg == null) {
return true;
}
const stepsOk = live?.steps == null || numClose(live.steps, defaults.steps, 0.5);
const cfgOk = live?.cfg == null || numClose(live.cfg, defaults.cfg);
const sigmaOk = defaults.sigma_shift == null
|| live?.sigma_shift == null
|| numClose(live.sigma_shift, defaults.sigma_shift);
return stepsOk && cfgOk && sigmaOk;
}
/**
* Keys that should be forced from Exact onto live before Generate.
* - Always rewrite live when it disagrees with Exact profile defaults.
* - Skip only when the patch sets a *different* intentional value, or
* sessionExact holds an override and userParamIntent is true.
* - Stale sessionExact leftovers (SD 20/7) must NOT block Exact.
*/
export function exactKeysToForce(live, defaults, {
patch = null,
sessionExact = null,
userParamIntent = false,
} = {}) {
if (!defaults) {
return [];
}
const out = [];
for (const key of ['steps', 'cfg', 'sigma_shift']) {
const want = defaults[key];
if (want == null) {
continue;
}
const eps = key === 'steps' ? 0.5 : 0.051;
// Patch asked for a non-Exact number — honor it.
if (patch && patch[key] != null && !numClose(patch[key], want, eps)) {
continue;
}
if (userParamIntent && sessionExact && sessionExact[key] != null) {
continue;
}
const have = live?.[key];
if (have == null || !numClose(have, want, eps)) {
out.push(key);
}
}
return out;
}
export function attachKreaProfile(SA) {
SA.kreaProfile = {
numClose,
detectKreaProfileName,
profileParamDefaults,
liveMatchesExactProfile,
exactKeysToForce,
};
}