genai-lite 0.3.1 → 0.3.2
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/dist/llm/LLMService.js
CHANGED
|
@@ -155,7 +155,8 @@ class LLMService {
|
|
|
155
155
|
// Check if native reasoning is active
|
|
156
156
|
const isNativeReasoningActive = modelInfo.reasoning?.supported === true &&
|
|
157
157
|
(internalRequest.settings.reasoning?.enabled === true ||
|
|
158
|
-
modelInfo.reasoning?.enabledByDefault === true
|
|
158
|
+
(modelInfo.reasoning?.enabledByDefault === true &&
|
|
159
|
+
internalRequest.settings.reasoning?.enabled !== false) || // Only if not explicitly disabled
|
|
159
160
|
modelInfo.reasoning?.canDisable === false); // Always-on models
|
|
160
161
|
effectiveOnMissing = isNativeReasoningActive ? 'ignore' : 'error';
|
|
161
162
|
}
|
|
@@ -544,6 +544,48 @@ describe('LLMService', () => {
|
|
|
544
544
|
const errorResponse = response;
|
|
545
545
|
expect(errorResponse.error.message).toContain('expected to start with a <reasoning> tag');
|
|
546
546
|
});
|
|
547
|
+
describe('auto mode with native reasoning detection', () => {
|
|
548
|
+
it('should enforce thinking tags for non-reasoning models by default', async () => {
|
|
549
|
+
// Mistral model doesn't have reasoning support
|
|
550
|
+
const request = {
|
|
551
|
+
providerId: 'mistral',
|
|
552
|
+
modelId: 'codestral-2501',
|
|
553
|
+
messages: [{ role: 'user', content: 'test_thinking:Response without thinking tag.' }],
|
|
554
|
+
settings: {
|
|
555
|
+
thinkingExtraction: {
|
|
556
|
+
enabled: true,
|
|
557
|
+
onMissing: 'auto'
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
const response = await service.sendMessage(request);
|
|
562
|
+
// Should error because model doesn't have native reasoning
|
|
563
|
+
expect(response.object).toBe('error');
|
|
564
|
+
const errorResponse = response;
|
|
565
|
+
expect(errorResponse.error.code).toBe('MISSING_EXPECTED_TAG');
|
|
566
|
+
expect(errorResponse.error.message).toContain('does not have native reasoning active');
|
|
567
|
+
});
|
|
568
|
+
it('should respect explicit reasoning.enabled: false even for models with enabledByDefault', async () => {
|
|
569
|
+
// This is the key test for the fix
|
|
570
|
+
const request = {
|
|
571
|
+
providerId: 'mistral',
|
|
572
|
+
modelId: 'codestral-2501',
|
|
573
|
+
messages: [{ role: 'user', content: 'test_thinking:Response without thinking tag.' }],
|
|
574
|
+
settings: {
|
|
575
|
+
reasoning: { enabled: false }, // Explicitly disabled
|
|
576
|
+
thinkingExtraction: {
|
|
577
|
+
enabled: true,
|
|
578
|
+
onMissing: 'auto'
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
const response = await service.sendMessage(request);
|
|
583
|
+
// Should error because reasoning is explicitly disabled
|
|
584
|
+
expect(response.object).toBe('error');
|
|
585
|
+
const errorResponse = response;
|
|
586
|
+
expect(errorResponse.error.code).toBe('MISSING_EXPECTED_TAG');
|
|
587
|
+
});
|
|
588
|
+
});
|
|
547
589
|
});
|
|
548
590
|
});
|
|
549
591
|
});
|