@zenmux/rosetta-ai 1.0.10 → 1.0.12
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.
|
@@ -775,6 +775,13 @@ class ResponsesToChatCompletionConverter {
|
|
|
775
775
|
messages.push({ role: "user", content: input });
|
|
776
776
|
return;
|
|
777
777
|
}
|
|
778
|
+
// Missing or non-array input: emit no messages and let the downstream
|
|
779
|
+
// ChatCompletions validation reject the request with a 400 (matching the
|
|
780
|
+
// legacy converter, which returned [] for undefined input rather than
|
|
781
|
+
// crashing).
|
|
782
|
+
if (!Array.isArray(input)) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
778
785
|
const pendingToolCalls = [];
|
|
779
786
|
const flushToolCalls = () => {
|
|
780
787
|
if (pendingToolCalls.length > 0) {
|
|
@@ -1125,7 +1132,7 @@ class ResponsesToChatCompletionConverter {
|
|
|
1125
1132
|
resp.top_logprobs = echoed.top_logprobs;
|
|
1126
1133
|
resp.safety_identifier =
|
|
1127
1134
|
echoed.safety_identifier != null ? echoed.safety_identifier : null;
|
|
1128
|
-
resp.service_tier = echoed.service_tier != null ? echoed.service_tier : "
|
|
1135
|
+
resp.service_tier = echoed.service_tier != null ? echoed.service_tier : "auto";
|
|
1129
1136
|
resp.prompt_cache_key =
|
|
1130
1137
|
this.requestParams?.prompt_cache_key !== undefined
|
|
1131
1138
|
? this.requestParams.prompt_cache_key
|
|
@@ -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.12",
|
|
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
|
+
}
|