Skip to content

Commit 748ded3

Browse files
fix(gateway): prioritize copilot chat models over copilotcli stubs in model discovery
1 parent 606f3fc commit 748ded3

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "GitHub Copilot API Gateway",
44
"description": "Free & open-source universal API Gateway for all VS Code language models. Auto-discovers GitHub Copilot, Gemini, Ollama & any AI extension — exposing them via local OpenAI, Anthropic, Google & Llama compatible APIs. One endpoint, every model. Use with Cursor, LangChain, Agents & more.",
55
"icon": "media/icon.png",
6-
"version": "2.11.6",
6+
"version": "2.11.7",
77
"author": {
88
"name": "Suhaib Bin Younis",
99
"email": "vscode@suhaib.in",

src/CopilotApiGateway.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4445,16 +4445,26 @@ export class CopilotApiGateway implements vscode.Disposable {
44454445
return null;
44464446
}
44474447

4448+
// Prioritize 'copilot' vendor over 'copilotcli' for identically named models
4449+
// so that standard chat streams don't sink into CLI stubs.
4450+
const sortedModels = [...availableModels].sort((a, b) => {
4451+
if (a.vendor === 'copilot' && b.vendor !== 'copilot') { return -1; }
4452+
if (a.vendor !== 'copilot' && b.vendor === 'copilot') { return 1; }
4453+
if (a.vendor === 'copilotcli' && b.vendor !== 'copilotcli') { return 1; }
4454+
if (a.vendor !== 'copilotcli' && b.vendor === 'copilotcli') { return -1; }
4455+
return 0;
4456+
});
4457+
44484458
const requested = requestedModel.toLowerCase();
44494459

44504460
// 1. Exact match on model id
4451-
const exactMatch = availableModels.find(m => m.id.toLowerCase() === requested);
4461+
const exactMatch = sortedModels.find(m => m.id.toLowerCase() === requested);
44524462
if (exactMatch) {
44534463
return exactMatch;
44544464
}
44554465

44564466
// 2. Exact match on family (e.g., "gpt-4o" matches family "gpt-4o")
4457-
const familyMatch = availableModels.find(m => m.family?.toLowerCase() === requested);
4467+
const familyMatch = sortedModels.find(m => m.family?.toLowerCase() === requested);
44584468
if (familyMatch) {
44594469
return familyMatch;
44604470
}
@@ -4463,7 +4473,7 @@ export class CopilotApiGateway implements vscode.Disposable {
44634473
// separators so "claude-3-5-sonnet-20241022" matches "claude-3.5-sonnet" etc.
44644474
const dateStripped = requested.replace(/-\d{8}$/, '');
44654475
const normed = dateStripped.replace(/\./g, '-');
4466-
const fuzzyMatch = availableModels.find(m => {
4476+
const fuzzyMatch = sortedModels.find(m => {
44674477
const mId = m.id.toLowerCase().replace('copilot-', '').replace(/\./g, '-');
44684478
const mFamily = (m.family || '').toLowerCase().replace('copilot-', '').replace(/\./g, '-');
44694479
return normed === mId || normed === mFamily ||

0 commit comments

Comments
 (0)