Compare commits

..

3 commits

Author SHA1 Message Date
igardev
79b90ef999
v0.0.47 2026-05-04 08:42:41 +03:00
igardev
a544d93511
API key for getting models list, ultiline field for Edit with AI, qwen3.5 models added
- API key is used (if needed and provided) on getting the list of models for adding OpenAI compatible provider
- Multiline field for Edit with AI
- Qwen3.5 models (2B, 4B, 9B) added in the predefined list  - good for tools and chat
2026-05-04 08:42:01 +03:00
Alexey Mekhanoshin
a73d9498ab
feat: add authorization headers to models fetch request (#180)
Adds support for the Authorization header when fetching the list of models from an OpenAI-compatible provider.
2026-04-30 07:59:35 +03:00
2 changed files with 38 additions and 18 deletions

View file

@ -2,7 +2,7 @@
"name": "llama-vscode",
"displayName": "llama-vscode",
"description": "Local LLM-assisted text completion using llama.cpp",
"version": "0.0.46",
"version": "0.0.47",
"publisher": "ggml-org",
"repository": "https://github.com/ggml-org/llama.vscode",
"engines": {

View file

@ -44,13 +44,13 @@ export class OpenAiCompModelStrategy implements IAddStrategy {
prompt: 'example: http://localhost:8080 or https://openrauter.ai/api'
})??""
isKeyRequired = await Utils.confirmAction(`Is API key required for this endpoint (${endpoint})?`, "");
}
}
if (!endpoint){
vscode.window.showWarningMessage("Endpoint is not provided!")
return;
}
const providerModels: QuickPickItem[] = [];
const models = await this.getModels(endpoint);
const models = await this.getModels(endpoint, isKeyRequired);
if (models.length == 0) {
vscode.window.showInformationMessage("No models are found.")
return
@ -108,30 +108,50 @@ export class OpenAiCompModelStrategy implements IAddStrategy {
}
}
private async getModels(endpoint: string): Promise<OpenAiCompModel[]> {
let hfEndpoint = Utils.trimTrailingSlash(endpoint) +"/v1/models";
private async getModels(endpoint: string, isKeyRequired: boolean): Promise<OpenAiCompModel[]> {
const hfEndpoint = Utils.trimTrailingSlash(endpoint) + "/v1/models";
// Create a request configuration
let requestConfig: any = {};
if (isKeyRequired) {
// We get the saved key for this specific endpoint
const apiKey = this.app.persistence.getApiKey(endpoint);
if (apiKey) {
requestConfig = {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
};
}
}
try {
let result = await axios.default.get(
`${Utils.trimTrailingSlash(hfEndpoint)}`
const result = await axios.default.get(
`${Utils.trimTrailingSlash(hfEndpoint)}`,
requestConfig
);
let models: OpenAiCompModel[] = [];
let modelsList: OpenAiCompModel[] = []
if (result && result.data && result.data.models) modelsList = result.data.models
else if (result && result.data && result.data.data) modelsList = result.data.data
if (modelsList.length > 0){
for(let mdl of modelsList){
models.push(mdl)
let modelsList: OpenAiCompModel[] = [];
if (result && result.data && result.data.models) modelsList = result.data.models;
else if (result && result.data && result.data.data) modelsList = result.data.data;
if (modelsList.length > 0) {
for (let mdl of modelsList) {
models.push(mdl);
}
}
return models;
} catch (error){
vscode.window.showErrorMessage("Error getting provider models): " + error)
} catch (error) {
vscode.window.showErrorMessage("Error getting provider models: " + error);
return [];
}
}
private sanitizeInput(input: string): string {
return input ? input.trim() : '';
}