@nanogpt/private-mode 0.2.18 → 0.2.19
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/lib/requestTransforms.js +24 -0
- package/package.json +1 -1
package/lib/requestTransforms.js
CHANGED
|
@@ -1021,6 +1021,29 @@ function applyTinfoilCompatibilityMutations(body, model) {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
|
|
1024
|
+
function stripEmptyPrivateModeToolDeclarations(body) {
|
|
1025
|
+
// Some OpenAI-compatible clients send inactive tool support as empty arrays.
|
|
1026
|
+
// Tinfoil rejects those arrays, so omit them and their dependent controls.
|
|
1027
|
+
if (Array.isArray(body.tools) && body.tools.length === 0) {
|
|
1028
|
+
const hasMessageTools = Array.isArray(body.messages) && body.messages.some(
|
|
1029
|
+
(message) => isPlainObject(message) &&
|
|
1030
|
+
message.role === 'system' &&
|
|
1031
|
+
Array.isArray(message.tools) &&
|
|
1032
|
+
message.tools.length > 0,
|
|
1033
|
+
);
|
|
1034
|
+
delete body.tools;
|
|
1035
|
+
if (!hasMessageTools) {
|
|
1036
|
+
delete body.tool_choice;
|
|
1037
|
+
delete body.parallel_tool_calls;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
if (Array.isArray(body.functions) && body.functions.length === 0) {
|
|
1042
|
+
delete body.functions;
|
|
1043
|
+
delete body.function_call;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1024
1047
|
function normalizeMaxTokenAliases(body) {
|
|
1025
1048
|
for (const key of MAX_TOKEN_ALIAS_FIELDS) {
|
|
1026
1049
|
if (body.max_tokens === undefined && body[key] !== undefined) {
|
|
@@ -1115,6 +1138,7 @@ export function applyPrivateModelRequestMutations(body, model) {
|
|
|
1115
1138
|
if (model.thinkingMode !== 'glm-5.3') delete body.reasoning_effort;
|
|
1116
1139
|
}
|
|
1117
1140
|
|
|
1141
|
+
stripEmptyPrivateModeToolDeclarations(body);
|
|
1118
1142
|
stripUnsupportedPrivateTinfoilFields(body);
|
|
1119
1143
|
return body;
|
|
1120
1144
|
}
|