Overwrite foreign steps/cfg in sparse patches when the user did not ask for params, and skip the cold-load path when Ollama already has the chat model resident. Co-authored-by: Cursor <cursoragent@cursor.com>
93 lines
3.1 KiB
JavaScript
93 lines
3.1 KiB
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
detectKreaProfileName,
|
|
profileParamDefaults,
|
|
liveMatchesExactProfile,
|
|
exactKeysToForce,
|
|
numClose,
|
|
} from '../src/kreaProfile.js';
|
|
|
|
const PROFILES = {
|
|
turbo: { steps: 8, cfg: 1, sigma_shift: 1.15 },
|
|
raw: { steps: 28, cfg: 4.5, sigma_shift: 1.15 },
|
|
};
|
|
|
|
describe('kreaProfile', () => {
|
|
it('detectKreaProfileName: turbo token wins', () => {
|
|
assert.equal(detectKreaProfileName('realismByStableYogi_v25INT8Turbo', 'raw'), 'turbo');
|
|
assert.equal(detectKreaProfileName('Krea2 Turbo fp8', 'raw'), 'turbo');
|
|
});
|
|
|
|
it('detectKreaProfileName: raw token without turbo', () => {
|
|
assert.equal(detectKreaProfileName('Krea2 RAW Base', 'turbo'), 'raw');
|
|
});
|
|
|
|
it('detectKreaProfileName: unlabeled Yogi is not fake turbo', () => {
|
|
assert.equal(detectKreaProfileName('realismByStableYogi_v25', 'turbo'), 'raw');
|
|
assert.equal(detectKreaProfileName('realismByStableYogi', null), 'raw');
|
|
});
|
|
|
|
it('liveMatchesExactProfile rejects SD leftovers under turbo', () => {
|
|
const turbo = profileParamDefaults(PROFILES, 'turbo');
|
|
assert.equal(liveMatchesExactProfile({ steps: 20, cfg: 7, sigma_shift: 1.15 }, turbo), false);
|
|
assert.equal(liveMatchesExactProfile({ steps: 8, cfg: 1, sigma_shift: 1.15 }, turbo), true);
|
|
});
|
|
|
|
it('exactKeysToForce overwrites 20/7 unless intentional non-Exact patch or user session', () => {
|
|
const turbo = profileParamDefaults(PROFILES, 'turbo');
|
|
assert.deepEqual(
|
|
exactKeysToForce({ steps: 20, cfg: 7, sigma_shift: 1 }, turbo, {}),
|
|
['steps', 'cfg', 'sigma_shift'],
|
|
);
|
|
// Injected Exact values in the patch still force live leftovers.
|
|
assert.deepEqual(
|
|
exactKeysToForce(
|
|
{ steps: 20, cfg: 7, sigma_shift: 1 },
|
|
turbo,
|
|
{ patch: { steps: 8, cfg: 1, sigma_shift: 1.15 } },
|
|
),
|
|
['steps', 'cfg', 'sigma_shift'],
|
|
);
|
|
// Stale sessionExact without user intent must not block Exact.
|
|
assert.deepEqual(
|
|
exactKeysToForce(
|
|
{ steps: 20, cfg: 7, sigma_shift: 1.15 },
|
|
turbo,
|
|
{ sessionExact: { steps: 20 }, userParamIntent: false },
|
|
),
|
|
['steps', 'cfg'],
|
|
);
|
|
assert.deepEqual(
|
|
exactKeysToForce(
|
|
{ steps: 20, cfg: 7, sigma_shift: 1.15 },
|
|
turbo,
|
|
{ sessionExact: { steps: 20 }, userParamIntent: true },
|
|
),
|
|
['cfg'],
|
|
);
|
|
// Intentional non-Exact patch value is kept.
|
|
assert.deepEqual(
|
|
exactKeysToForce({ steps: 20, cfg: 7, sigma_shift: 1.15 }, turbo, { patch: { cfg: 7 } }),
|
|
['steps', 'cfg'],
|
|
);
|
|
assert.deepEqual(
|
|
exactKeysToForce(
|
|
{ steps: 20, cfg: 7, sigma_shift: 1.15 },
|
|
turbo,
|
|
{ patch: { cfg: 7 }, userParamIntent: true },
|
|
),
|
|
['steps'],
|
|
);
|
|
assert.deepEqual(
|
|
exactKeysToForce({ steps: 8, cfg: 1, sigma_shift: 1.15 }, turbo, {}),
|
|
[],
|
|
);
|
|
});
|
|
|
|
it('numClose', () => {
|
|
assert.equal(numClose(1.15, 1.14), true);
|
|
assert.equal(numClose(1, 7), false);
|
|
});
|
|
});
|