@jsonstudio/llms 0.6.3271 → 0.6.3275
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.
|
@@ -16,6 +16,42 @@ function readTrimmedString(value) {
|
|
|
16
16
|
const trimmed = value.trim();
|
|
17
17
|
return trimmed.length ? trimmed : undefined;
|
|
18
18
|
}
|
|
19
|
+
function shouldInjectThinking(value) {
|
|
20
|
+
if (value === undefined || value === null) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === 'boolean') {
|
|
24
|
+
return value !== false;
|
|
25
|
+
}
|
|
26
|
+
if (isRecord(value)) {
|
|
27
|
+
const type = readTrimmedString(value.type);
|
|
28
|
+
return !type;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
return value.trim().length === 0;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
function resolveEffort(model) {
|
|
36
|
+
const modelId = readTrimmedString(model)?.toLowerCase() || '';
|
|
37
|
+
return modelId.startsWith('glm-5') ? 'high' : 'medium';
|
|
38
|
+
}
|
|
39
|
+
function ensureAdaptiveThinking(root) {
|
|
40
|
+
if (shouldInjectThinking(root.thinking)) {
|
|
41
|
+
root.thinking = { type: 'adaptive' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function ensureOutputEffort(root) {
|
|
45
|
+
const effort = resolveEffort(root.model);
|
|
46
|
+
if (isRecord(root.output_config)) {
|
|
47
|
+
const outputConfig = root.output_config;
|
|
48
|
+
if (!readTrimmedString(outputConfig.effort)) {
|
|
49
|
+
outputConfig.effort = effort;
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
root.output_config = { effort };
|
|
54
|
+
}
|
|
19
55
|
function isClaudeCodeUserId(value) {
|
|
20
56
|
const trimmed = readTrimmedString(value);
|
|
21
57
|
if (!trimmed)
|
|
@@ -209,6 +245,8 @@ export function applyAnthropicClaudeCodeSystemPromptCompat(payload, config, adap
|
|
|
209
245
|
.filter((b) => b.text !== systemText);
|
|
210
246
|
// Normalize: force system into a single text block.
|
|
211
247
|
root.system = [{ type: 'text', text: systemText }];
|
|
248
|
+
ensureAdaptiveThinking(root);
|
|
249
|
+
ensureOutputEffort(root);
|
|
212
250
|
if (preserveExisting && existingBlocks.length) {
|
|
213
251
|
const messages = Array.isArray(root.messages) ? root.messages : [];
|
|
214
252
|
if (messages.length || root.messages !== undefined) {
|
|
Binary file
|