sapper-iq 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sapper.mjs +29 -8
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -1016,6 +1016,9 @@ project/
|
|
|
1016
1016
|
// Global flag — set after model selection, read in buildSystemPrompt
|
|
1017
1017
|
let _useNativeToolsFlag = false;
|
|
1018
1018
|
|
|
1019
|
+
// Models known to reject `think:true` (populated lazily on first failure).
|
|
1020
|
+
const modelsWithoutThinking = new Set();
|
|
1021
|
+
|
|
1019
1022
|
function buildSystemPrompt(agentContent = null, skillContents = []) {
|
|
1020
1023
|
const now = new Date();
|
|
1021
1024
|
const dateStr = now.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
@@ -8621,8 +8624,9 @@ async function runSapper() {
|
|
|
8621
8624
|
}
|
|
8622
8625
|
return { result, success: true };
|
|
8623
8626
|
}
|
|
8624
|
-
|
|
8625
|
-
|
|
8627
|
+
let turnThinkingEnabled = shouldUseThinkingForInput(input);
|
|
8628
|
+
if (modelsWithoutThinking.has(selectedModel)) turnThinkingEnabled = false;
|
|
8629
|
+
|
|
8626
8630
|
let active = true;
|
|
8627
8631
|
while (active) {
|
|
8628
8632
|
if (stepMode) await safeQuestion(chalk.gray(promptLabel('questions.stepContinue', '[STEP] Press Enter to let AI think...')));
|
|
@@ -8637,7 +8641,7 @@ async function runSapper() {
|
|
|
8637
8641
|
chatOpts.options = { num_ctx: effectiveContextLength() };
|
|
8638
8642
|
}
|
|
8639
8643
|
// Thinking can be forced on, forced off, or auto-disabled for simple prompts.
|
|
8640
|
-
chatOpts.think =
|
|
8644
|
+
if (turnThinkingEnabled) chatOpts.think = true;
|
|
8641
8645
|
if (useNativeTools) {
|
|
8642
8646
|
// Filter tool defs by agent restrictions if any
|
|
8643
8647
|
if (currentAgentTools) {
|
|
@@ -8657,11 +8661,28 @@ async function runSapper() {
|
|
|
8657
8661
|
}
|
|
8658
8662
|
response = await ollama.chat(chatOpts);
|
|
8659
8663
|
} catch (ollamaError) {
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8664
|
+
const errMsg = ollamaError && ollamaError.message ? ollamaError.message : String(ollamaError);
|
|
8665
|
+
if (/does not support thinking/i.test(errMsg) && chatOpts.think) {
|
|
8666
|
+
modelsWithoutThinking.add(selectedModel);
|
|
8667
|
+
turnThinkingEnabled = false;
|
|
8668
|
+
delete chatOpts.think;
|
|
8669
|
+
console.log(chalk.yellow(` ⚠ "${selectedModel}" doesn't support thinking — retrying without it.`));
|
|
8670
|
+
try {
|
|
8671
|
+
response = await ollama.chat(chatOpts);
|
|
8672
|
+
} catch (retryErr) {
|
|
8673
|
+
spinner.stop();
|
|
8674
|
+
console.error(chalk.red('\n❌ Ollama error:'), retryErr.message);
|
|
8675
|
+
logEntry('error', { message: `Ollama error: ${retryErr.message}` });
|
|
8676
|
+
active = false;
|
|
8677
|
+
continue;
|
|
8678
|
+
}
|
|
8679
|
+
} else {
|
|
8680
|
+
spinner.stop();
|
|
8681
|
+
console.error(chalk.red('\n❌ Ollama error:'), errMsg);
|
|
8682
|
+
logEntry('error', { message: `Ollama error: ${errMsg}` });
|
|
8683
|
+
active = false;
|
|
8684
|
+
continue;
|
|
8685
|
+
}
|
|
8665
8686
|
}
|
|
8666
8687
|
spinner.stop();
|
|
8667
8688
|
|