@zenmux/rosetta-ai 1.0.11 → 1.0.13
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.
|
@@ -135,8 +135,10 @@ class ResponsesToChatCompletionConverter {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
// Message
|
|
139
|
-
|
|
138
|
+
// Message — legacy emitted the message item only when content was truthy
|
|
139
|
+
// (empty-string content with e.g. max_output_tokens exhausted was skipped).
|
|
140
|
+
// Refusal is also surfaced as a message when present.
|
|
141
|
+
if (msg?.content || msg?.refusal) {
|
|
140
142
|
const content = [];
|
|
141
143
|
if (msg.refusal) {
|
|
142
144
|
content.push({ type: "refusal", refusal: msg.refusal });
|
|
@@ -290,7 +292,7 @@ class ResponsesToChatCompletionConverter {
|
|
|
290
292
|
properties: t.parameters.properties ?? {},
|
|
291
293
|
required: t.parameters.required ?? [],
|
|
292
294
|
},
|
|
293
|
-
strict: t.strict,
|
|
295
|
+
strict: t.strict ?? true,
|
|
294
296
|
};
|
|
295
297
|
}
|
|
296
298
|
if (t.type === "web_search" ||
|
|
@@ -775,6 +777,13 @@ class ResponsesToChatCompletionConverter {
|
|
|
775
777
|
messages.push({ role: "user", content: input });
|
|
776
778
|
return;
|
|
777
779
|
}
|
|
780
|
+
// Missing or non-array input: emit no messages and let the downstream
|
|
781
|
+
// ChatCompletions validation reject the request with a 400 (matching the
|
|
782
|
+
// legacy converter, which returned [] for undefined input rather than
|
|
783
|
+
// crashing).
|
|
784
|
+
if (!Array.isArray(input)) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
778
787
|
const pendingToolCalls = [];
|
|
779
788
|
const flushToolCalls = () => {
|
|
780
789
|
if (pendingToolCalls.length > 0) {
|
|
@@ -37,7 +37,7 @@ class ResponsesToMessagesConverter {
|
|
|
37
37
|
result.tool_choice = this.convertToolChoice(params.tool_choice, params.parallel_tool_calls);
|
|
38
38
|
}
|
|
39
39
|
if (params.reasoning) {
|
|
40
|
-
result.thinking = this.convertReasoning(params.reasoning);
|
|
40
|
+
result.thinking = this.convertReasoning(params.reasoning, result.max_tokens);
|
|
41
41
|
}
|
|
42
42
|
if (params.text?.format?.type === "json_schema") {
|
|
43
43
|
const fmt = params.text.format;
|
|
@@ -945,17 +945,24 @@ class ResponsesToMessagesConverter {
|
|
|
945
945
|
}
|
|
946
946
|
return { type: "auto" };
|
|
947
947
|
}
|
|
948
|
-
convertReasoning(reasoning) {
|
|
948
|
+
convertReasoning(reasoning, maxOutputTokens) {
|
|
949
949
|
if (!reasoning || !reasoning.effort) {
|
|
950
|
+
return undefined;
|
|
951
|
+
}
|
|
952
|
+
else if (reasoning.effort === "none") {
|
|
950
953
|
return { type: "disabled" };
|
|
951
954
|
}
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
955
|
+
const effortRatioMap = {
|
|
956
|
+
minimal: 0.1,
|
|
957
|
+
low: 0.2,
|
|
958
|
+
medium: 0.5,
|
|
959
|
+
high: 0.8,
|
|
960
|
+
xhigh: 0.9,
|
|
961
|
+
max: 0.95,
|
|
956
962
|
};
|
|
957
|
-
const
|
|
958
|
-
|
|
963
|
+
const ratio = effortRatioMap[reasoning.effort] ?? effortRatioMap.minimal;
|
|
964
|
+
const budget = Math.floor(maxOutputTokens * ratio);
|
|
965
|
+
return { type: "enabled", budget_tokens: Math.max(budget, 1024) };
|
|
959
966
|
}
|
|
960
967
|
// --- Private: response helpers ---
|
|
961
968
|
stopReasonToStatus(stopReason, content) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenmux/rosetta-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Universal translator between AI provider protocols",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
"typescript": "^6.0.2",
|
|
61
61
|
"typescript-eslint": "^8.58.2"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|