Harden Exact reconcile and soften post-Generate warm.
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>
This commit is contained in:
+34
-11
@@ -667,6 +667,12 @@
|
||||
const clearSessionKeys = [];
|
||||
for (const key of EXACT_GENERATE_PARAM_KEYS) {
|
||||
if (out[key] != null) {
|
||||
if (!userParamIntent && defaults[key] != null && String(out[key]) !== String(defaults[key])) {
|
||||
out[key] = defaults[key];
|
||||
if (sessionExact?.[key] != null && String(sessionExact[key]) !== String(defaults[key])) {
|
||||
clearSessionKeys.push(key);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (userParamIntent && sessionExact?.[key] != null) {
|
||||
@@ -1140,7 +1146,7 @@
|
||||
continue;
|
||||
}
|
||||
const eps = key === "steps" ? 0.5 : 0.051;
|
||||
if (patch && patch[key] != null && !numClose(patch[key], want, eps)) {
|
||||
if (userParamIntent && patch && patch[key] != null && !numClose(patch[key], want, eps)) {
|
||||
continue;
|
||||
}
|
||||
if (userParamIntent && sessionExact && sessionExact[key] != null) {
|
||||
@@ -2361,7 +2367,7 @@ ${patch.prompt}`;
|
||||
if (want == null) {
|
||||
return false;
|
||||
}
|
||||
if (patch?.[k] != null && String(patch[k]) !== String(want)) {
|
||||
if (userIntent && patch?.[k] != null && String(patch[k]) !== String(want)) {
|
||||
return false;
|
||||
}
|
||||
if (userIntent && state.sessionExact?.[k] != null) {
|
||||
@@ -5496,16 +5502,16 @@ ${patch.prompt}`;
|
||||
return new Promise((resolve) => {
|
||||
const model = $2("sa_model")?.value;
|
||||
if (!model || typeof genericRequest !== "function") {
|
||||
resolve(false);
|
||||
resolve({ ok: false, alreadyResident: false });
|
||||
return;
|
||||
}
|
||||
if (!force && !state.llmParked) {
|
||||
resolve(false);
|
||||
resolve({ ok: false, alreadyResident: false });
|
||||
return;
|
||||
}
|
||||
const baseUrl = $2("sa_base_url")?.value || "http://127.0.0.1:11434";
|
||||
let settled = false;
|
||||
const finish = (ok) => {
|
||||
const finish = (ok, alreadyResident = false) => {
|
||||
if (settled) {
|
||||
return;
|
||||
}
|
||||
@@ -5514,10 +5520,19 @@ ${patch.prompt}`;
|
||||
if (ok) {
|
||||
state.expectColdLoad = false;
|
||||
}
|
||||
resolve(!!ok);
|
||||
resolve({ ok: !!ok, alreadyResident: !!alreadyResident });
|
||||
};
|
||||
setTimeout(() => finish(false), 18e4);
|
||||
genericRequest("AssistentWarmLlm", { baseUrl, model }, () => finish(true), 0, () => finish(false));
|
||||
genericRequest(
|
||||
"AssistentWarmLlm",
|
||||
{ baseUrl, model },
|
||||
(data) => {
|
||||
const skipped = !!(data && (data.skipped === "already_resident" || data.already_resident === true));
|
||||
finish(true, skipped);
|
||||
},
|
||||
0,
|
||||
() => finish(false)
|
||||
);
|
||||
});
|
||||
}
|
||||
function cancelWaitForNewImage() {
|
||||
@@ -5845,7 +5860,8 @@ ${patch.prompt}`;
|
||||
}
|
||||
state.generating = false;
|
||||
setInterruptVisible(state.busy);
|
||||
state.expectColdLoad = true;
|
||||
const parkedBeforeWarm = !!state.llmParked;
|
||||
state.expectColdLoad = parkedBeforeWarm;
|
||||
if (jobs && lastSrc && state.selectedGenResultId && epoch === state.chatEpoch) {
|
||||
const row = state.genResults.find((r) => r.id === state.selectedGenResultId);
|
||||
if (row?.patch) {
|
||||
@@ -5857,9 +5873,16 @@ ${patch.prompt}`;
|
||||
const multiDone = !!(jobs && finishedGenResultCount() > 1);
|
||||
const willAutoCritique = !multiDone && !!$2("sa_auto_critique")?.checked;
|
||||
if (state.view === "chat" && paneVisible && !willAutoCritique && epoch === state.chatEpoch) {
|
||||
startBusyUi("warming");
|
||||
setStatus("\u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u044E LLM \u0432 GPU\u2026");
|
||||
await warmLlm({ force: true });
|
||||
if (parkedBeforeWarm || state.expectColdLoad) {
|
||||
startBusyUi("warming");
|
||||
setStatus("\u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u044E LLM \u0432 GPU\u2026");
|
||||
}
|
||||
const warmResult = await warmLlm({ force: true });
|
||||
if (warmResult?.alreadyResident) {
|
||||
state.expectColdLoad = false;
|
||||
} else if (!warmResult?.ok) {
|
||||
state.expectColdLoad = true;
|
||||
}
|
||||
}
|
||||
if (epoch !== state.chatEpoch) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user