@dianshuv/copilot-api 0.6.1 → 0.6.2
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.mjs +26 -2
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1036,7 +1036,7 @@ const patchClaude = defineCommand({
|
|
|
1036
1036
|
|
|
1037
1037
|
//#endregion
|
|
1038
1038
|
//#region package.json
|
|
1039
|
-
var version = "0.6.
|
|
1039
|
+
var version = "0.6.2";
|
|
1040
1040
|
|
|
1041
1041
|
//#endregion
|
|
1042
1042
|
//#region src/lib/adaptive-rate-limiter.ts
|
|
@@ -4483,6 +4483,30 @@ function handleNonStreamResponse(c, response, model, ctx, payload) {
|
|
|
4483
4483
|
return c.json(geminiResponse);
|
|
4484
4484
|
}
|
|
4485
4485
|
|
|
4486
|
+
//#endregion
|
|
4487
|
+
//#region src/routes/gemini/model-alias.ts
|
|
4488
|
+
/**
|
|
4489
|
+
* Maps Gemini model names that aren't available on GitHub Copilot
|
|
4490
|
+
* to equivalent models that are.
|
|
4491
|
+
*
|
|
4492
|
+
* The Gemini CLI's routing classifier requests gemini-2.5-flash-lite
|
|
4493
|
+
* and gemini-2.5-flash, which Copilot doesn't serve. We map them to
|
|
4494
|
+
* the closest available flash model.
|
|
4495
|
+
*
|
|
4496
|
+
* Aliases are only applied when the requested model is absent from
|
|
4497
|
+
* the Copilot model list, so if Copilot adds support for these models
|
|
4498
|
+
* natively, requests will go through unchanged.
|
|
4499
|
+
*/
|
|
4500
|
+
const GEMINI_MODEL_ALIASES = {
|
|
4501
|
+
"gemini-2.5-flash-lite": "gemini-3-flash-preview",
|
|
4502
|
+
"gemini-2.5-flash": "gemini-3-flash-preview"
|
|
4503
|
+
};
|
|
4504
|
+
function resolveGeminiModelAlias(model) {
|
|
4505
|
+
if (!(model in GEMINI_MODEL_ALIASES)) return model;
|
|
4506
|
+
if (state.models?.data.some((m) => m.id === model)) return model;
|
|
4507
|
+
return GEMINI_MODEL_ALIASES[model];
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4486
4510
|
//#endregion
|
|
4487
4511
|
//#region src/routes/gemini/route.ts
|
|
4488
4512
|
const geminiRoutes = new Hono();
|
|
@@ -4490,7 +4514,7 @@ geminiRoutes.post("/:modelAction", async (c) => {
|
|
|
4490
4514
|
const modelAction = c.req.param("modelAction");
|
|
4491
4515
|
const colonIndex = modelAction.lastIndexOf(":");
|
|
4492
4516
|
if (colonIndex === -1) return geminiError(c, 400, "INVALID_ARGUMENT", "Missing action in URL");
|
|
4493
|
-
const model = modelAction.slice(0, Math.max(0, colonIndex));
|
|
4517
|
+
const model = resolveGeminiModelAlias(modelAction.slice(0, Math.max(0, colonIndex)));
|
|
4494
4518
|
const action = modelAction.slice(Math.max(0, colonIndex + 1));
|
|
4495
4519
|
switch (action) {
|
|
4496
4520
|
case "generateContent": return handleGeminiGenerate(c, model, false);
|