diff --git a/src/extension.ts b/src/extension.ts index fb2172c..10531c1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,9 +1,39 @@ import * as vscode from 'vscode'; +const BASE_URL = 'https://gateway.inference.coop/v1'; + export function activate(context: vscode.ExtensionContext) { const provider: vscode.LanguageModelChatProvider = { async provideLanguageModelChatInformation() { - return []; + const key = vscode.workspace + .getConfiguration('inferenceCoop') + .get('apiKey'); + if (!key) { + return []; + } + + const res = await fetch(`${BASE_URL}/models`, { + headers: { Authorization: `Bearer ${key}` } + }); + if (!res.ok) { + vscode.window.showErrorMessage( + `Inference Coop: model list failed (HTTP ${res.status})` + ); + return []; + } + + const body = (await res.json()) as { data: Array<{ id: string; mode?: string }> }; + return body.data + .filter(m => !m.mode || m.mode === 'chat') + .map(m => ({ + id: m.id, + name: m.id, + family: 'inference-coop', + version: '1.0.0', + maxInputTokens: 131072, + maxOutputTokens: 8192, + capabilities: { toolCalling: true, imageInput: false } + })); }, async provideLanguageModelChatResponse() { throw new Error('Not implemented yet');