diff --git a/core/config/load.ts b/core/config/load.ts index 30df0fd75..065842052 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -282,6 +282,7 @@ async function intermediateToFinalConfig({ ...desc, model: modelName, title: modelName, + isFromAutoDetect: true, }, ide.readFile.bind(ide), getUriFromPath, @@ -319,6 +320,7 @@ async function intermediateToFinalConfig({ ...desc.options, model: modelName, logger: llmLogger, + isFromAutoDetect: true, }, }), ); @@ -626,6 +628,7 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription { apiKeyLocation: llm.apiKeyLocation, envSecretLocations: llm.envSecretLocations, sourceFile: llm.sourceFile, + isFromAutoDetect: llm.isFromAutoDetect, }; } diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 102e4152b..45cbdcbfb 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -32,12 +32,14 @@ async function modelConfigToBaseLLM({ ideSettings, llmLogger, config, + isFromAutoDetect, }: { model: ModelConfig; uniqueId: string; ideSettings: IdeSettings; llmLogger: ILLMLogger; config: ContinueConfig; + isFromAutoDetect?: boolean; }): Promise { const cls = getModelClass(model); @@ -71,6 +73,7 @@ async function modelConfigToBaseLLM({ nextEdit: model.capabilities?.includes("next_edit"), }, autocompleteOptions: model.autocompleteOptions, + isFromAutoDetect, }; // Model capabilities - need to be undefined if not found @@ -173,7 +176,6 @@ async function autodetectModels({ if (modelName === AUTODETECT) { return undefined; } - return await modelConfigToBaseLLM({ model: { ...model, @@ -184,6 +186,7 @@ async function autodetectModels({ ideSettings, llmLogger, config, + isFromAutoDetect: true, }); }), ); diff --git a/core/index.d.ts b/core/index.d.ts index d639583ef..10966f084 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -666,6 +666,7 @@ export interface LLMOptions { env?: Record; sourceFile?: string; + isFromAutoDetect?: boolean; } type RequireAtLeastOne = Pick< @@ -1177,6 +1178,7 @@ export interface ModelDescription { configurationStatus?: LLMConfigurationStatuses; sourceFile?: string; + isFromAutoDetect?: boolean; } export interface JSONEmbedOptions { @@ -1607,6 +1609,7 @@ export interface JSONModelDescription { aiGatewaySlug?: string; useLegacyCompletionsEndpoint?: boolean; deploymentId?: string; + isFromAutoDetect?: boolean; } // config.json diff --git a/core/llm/index.ts b/core/llm/index.ts index edbfecbdb..1a0330eaa 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -9,7 +9,6 @@ import { import Handlebars from "handlebars"; import { DevDataSqliteDb } from "../data/devdataSqlite.js"; -import { Logger } from "../util/Logger.js"; import { DataLogger } from "../data/log.js"; import { CacheBehavior, @@ -31,6 +30,7 @@ import { TemplateType, Usage, } from "../index.js"; +import { Logger } from "../util/Logger.js"; import mergeJson from "../util/merge.js"; import { renderChatMessage } from "../util/messageContent.js"; import { isOllamaInstalled } from "../util/ollamaHelper.js"; @@ -191,6 +191,8 @@ export abstract class BaseLLM implements ILLM { //URI to local block defining this LLM sourceFile?: string; + isFromAutoDetect?: boolean; + private _llmOptions: LLMOptions; protected openaiAdapter?: BaseLlmApi; @@ -294,6 +296,7 @@ export abstract class BaseLLM implements ILLM { this.autocompleteOptions = options.autocompleteOptions; this.sourceFile = options.sourceFile; + this.isFromAutoDetect = options.isFromAutoDetect; } get contextLength() { diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index a944f90f9..a1c4c2046 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -148,7 +148,7 @@ class Ollama extends BaseLLM implements ModelInstaller { constructor(options: LLMOptions) { super(options); - if (options.model === "AUTODETECT") { + if (options.isFromAutoDetect) { return; } const headers: Record = { diff --git a/core/llm/llms/Vllm.ts b/core/llm/llms/Vllm.ts index 9dfd25a58..66f9b84c4 100644 --- a/core/llm/llms/Vllm.ts +++ b/core/llm/llms/Vllm.ts @@ -25,7 +25,7 @@ class Vllm extends OpenAI { constructor(options: LLMOptions) { super(options); - if (options.model === "AUTODETECT") { + if (options.isFromAutoDetect) { this._setupCompletionOptions(); } } diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 5aa221609..3108e7089 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -37,6 +37,7 @@ interface Option { title: string; apiKey?: string; sourceFile?: string; + isAutoDetected?: boolean; } function modelSelectTitle(model: any): string { @@ -75,8 +76,15 @@ function ModelOption({ {option.title} + {option.isAutoDetected && ( + + (autodetected) + + )} {showMissingApiKeyMsg && ( - (Missing API key) + + (Missing API key) + )} @@ -132,6 +140,7 @@ function ModelSelect() { title: modelSelectTitle(model), apiKey: model.apiKey, sourceFile: model.sourceFile, + isAutoDetected: model.isFromAutoDetect, }; }), );