forked from evanp/inference-coop-copilot
feat: get real models
This commit is contained in:
1 file changed
+30
@@ -1,9 +1,39 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
const BASE_URL = 'https://gateway.inference.coop/v1';
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
const provider: vscode.LanguageModelChatProvider = {
|
const provider: vscode.LanguageModelChatProvider = {
|
||||||
async provideLanguageModelChatInformation() {
|
async provideLanguageModelChatInformation() {
|
||||||
|
const key = vscode.workspace
|
||||||
|
.getConfiguration('inferenceCoop')
|
||||||
|
.get<string>('apiKey');
|
||||||
|
if (!key) {
|
||||||
return [];
|
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() {
|
async provideLanguageModelChatResponse() {
|
||||||
throw new Error('Not implemented yet');
|
throw new Error('Not implemented yet');
|
||||||
|
|||||||
Reference in new issue
Block a user