copilot-api-plus 1.2.51 → 1.2.52
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/main.js +29 -10
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2184,9 +2184,12 @@ async function createWithSingleAccount(payload) {
|
|
|
2184
2184
|
}
|
|
2185
2185
|
if (!response.ok) {
|
|
2186
2186
|
const errorBody = await response.text();
|
|
2187
|
-
if (response.status === 400)
|
|
2188
|
-
|
|
2189
|
-
|
|
2187
|
+
if (response.status === 400) {
|
|
2188
|
+
const isExpectedReasoningError = errorBody.includes("reasoning_effort") || errorBody.includes("invalid_reasoning_effort") || errorBody.includes("does not support reasoning");
|
|
2189
|
+
const isModelNotSupported = errorBody.includes("model_not_supported");
|
|
2190
|
+
if (isExpectedReasoningError || isModelNotSupported) consola.debug(`400 (auto-handled): ${errorBody}`);
|
|
2191
|
+
else consola.warn(`400: ${errorBody}`);
|
|
2192
|
+
} else consola.error("Failed to create chat completions", {
|
|
2190
2193
|
status: response.status,
|
|
2191
2194
|
statusText: response.statusText,
|
|
2192
2195
|
body: errorBody
|
|
@@ -2426,9 +2429,12 @@ async function doFetch(payload, source, accountId) {
|
|
|
2426
2429
|
});
|
|
2427
2430
|
if (!response.ok) {
|
|
2428
2431
|
const errorBody = await response.text();
|
|
2429
|
-
if (response.status === 400)
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
+
if (response.status === 400) {
|
|
2433
|
+
const isExpectedReasoningError = errorBody.includes("reasoning_effort") || errorBody.includes("invalid_reasoning_effort") || errorBody.includes("does not support reasoning");
|
|
2434
|
+
const isModelNotSupported = errorBody.includes("model_not_supported");
|
|
2435
|
+
if (isExpectedReasoningError || isModelNotSupported) consola.debug(`400 (auto-handled): ${errorBody}`);
|
|
2436
|
+
else consola.warn(`400: ${errorBody}`);
|
|
2437
|
+
} else consola.error("Failed to create chat completions", {
|
|
2432
2438
|
status: response.status,
|
|
2433
2439
|
statusText: response.statusText,
|
|
2434
2440
|
body: errorBody
|
|
@@ -2775,11 +2781,20 @@ function translateModelName(model) {
|
|
|
2775
2781
|
const supportedModels = state.models?.data.map((m) => m.id) ?? [];
|
|
2776
2782
|
if (supportedModels.includes(model)) return model;
|
|
2777
2783
|
const modelBase = model.replace(/-\d{8}$/, "");
|
|
2778
|
-
if (supportedModels.includes(modelBase))
|
|
2784
|
+
if (supportedModels.includes(modelBase)) {
|
|
2785
|
+
consola.debug(`Model name: "${model}" → "${modelBase}" (stripped date suffix)`);
|
|
2786
|
+
return modelBase;
|
|
2787
|
+
}
|
|
2779
2788
|
const modelWithDot = modelBase.replace(/-(\d+)-(\d+)$/, "-$1.$2");
|
|
2780
|
-
if (supportedModels.includes(modelWithDot))
|
|
2789
|
+
if (supportedModels.includes(modelWithDot)) {
|
|
2790
|
+
consola.debug(`Model name: "${model}" → "${modelWithDot}" (dash→dot)`);
|
|
2791
|
+
return modelWithDot;
|
|
2792
|
+
}
|
|
2781
2793
|
const modelWithDash = model.replace(/(\d+)\.(\d+)/, "$1-$2");
|
|
2782
|
-
if (supportedModels.includes(modelWithDash))
|
|
2794
|
+
if (supportedModels.includes(modelWithDash)) {
|
|
2795
|
+
consola.debug(`Model name: "${model}" → "${modelWithDash}" (dot→dash)`);
|
|
2796
|
+
return modelWithDash;
|
|
2797
|
+
}
|
|
2783
2798
|
for (const [oldFormat, newFormat] of Object.entries({
|
|
2784
2799
|
"claude-3-5-sonnet": "claude-sonnet-4.5",
|
|
2785
2800
|
"claude-3-sonnet": "claude-sonnet-4",
|
|
@@ -2787,7 +2802,11 @@ function translateModelName(model) {
|
|
|
2787
2802
|
"claude-3-opus": "claude-opus-4.5",
|
|
2788
2803
|
"claude-3-5-haiku": "claude-haiku-4.5",
|
|
2789
2804
|
"claude-3-haiku": "claude-haiku-4.5"
|
|
2790
|
-
})) if (modelBase.startsWith(oldFormat) && supportedModels.includes(newFormat))
|
|
2805
|
+
})) if (modelBase.startsWith(oldFormat) && supportedModels.includes(newFormat)) {
|
|
2806
|
+
consola.debug(`Model name: "${model}" → "${newFormat}" (legacy mapping)`);
|
|
2807
|
+
return newFormat;
|
|
2808
|
+
}
|
|
2809
|
+
consola.warn(`Model name: "${model}" not found in supported models list, passing as-is`);
|
|
2791
2810
|
return model;
|
|
2792
2811
|
}
|
|
2793
2812
|
function translateAnthropicMessagesToOpenAI(anthropicMessages, system) {
|