fix: pass autodetected around as boolean
This commit is contained in:
parent
75186ddadb
commit
bf8b4bd8c1
7 changed files with 23 additions and 7 deletions
|
|
@ -277,12 +277,12 @@ async function intermediateToFinalConfig({
|
|||
const modelNames = await llm.listModels();
|
||||
const detectedModels = await Promise.all(
|
||||
modelNames.map(async (modelName) => {
|
||||
const autodetectTitle = `${desc.title || desc.model} (auto-detected)`;
|
||||
return await llmFromDescription(
|
||||
{
|
||||
...desc,
|
||||
model: modelName,
|
||||
title: autodetectTitle,
|
||||
title: modelName,
|
||||
isFromAutoDetect: true,
|
||||
},
|
||||
ide.readFile.bind(ide),
|
||||
getUriFromPath,
|
||||
|
|
@ -320,6 +320,7 @@ async function intermediateToFinalConfig({
|
|||
...desc.options,
|
||||
model: modelName,
|
||||
logger: llmLogger,
|
||||
isFromAutoDetect: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
|
@ -627,6 +628,7 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription {
|
|||
apiKeyLocation: llm.apiKeyLocation,
|
||||
envSecretLocations: llm.envSecretLocations,
|
||||
sourceFile: llm.sourceFile,
|
||||
isFromAutoDetect: llm.isFromAutoDetect,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,14 @@ async function modelConfigToBaseLLM({
|
|||
ideSettings,
|
||||
llmLogger,
|
||||
config,
|
||||
isFromAutoDetect,
|
||||
}: {
|
||||
model: ModelConfig;
|
||||
uniqueId: string;
|
||||
ideSettings: IdeSettings;
|
||||
llmLogger: ILLMLogger;
|
||||
config: ContinueConfig;
|
||||
isFromAutoDetect?: boolean;
|
||||
}): Promise<BaseLLM | undefined> {
|
||||
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,17 +176,17 @@ async function autodetectModels({
|
|||
if (modelName === AUTODETECT) {
|
||||
return undefined;
|
||||
}
|
||||
const autodetectTitle = `${modelName} (auto-detected)`;
|
||||
return await modelConfigToBaseLLM({
|
||||
model: {
|
||||
...model,
|
||||
model: modelName,
|
||||
name: autodetectTitle,
|
||||
name: modelName,
|
||||
},
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
llmLogger,
|
||||
config,
|
||||
isFromAutoDetect: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
3
core/index.d.ts
vendored
3
core/index.d.ts
vendored
|
|
@ -666,6 +666,7 @@ export interface LLMOptions {
|
|||
env?: Record<string, string | number | boolean>;
|
||||
|
||||
sourceFile?: string;
|
||||
isFromAutoDetect?: boolean;
|
||||
}
|
||||
|
||||
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
||||
|
|
@ -1175,6 +1176,7 @@ export interface ModelDescription {
|
|||
configurationStatus?: LLMConfigurationStatuses;
|
||||
|
||||
sourceFile?: string;
|
||||
isFromAutoDetect?: boolean;
|
||||
}
|
||||
|
||||
export interface JSONEmbedOptions {
|
||||
|
|
@ -1605,6 +1607,7 @@ export interface JSONModelDescription {
|
|||
aiGatewaySlug?: string;
|
||||
useLegacyCompletionsEndpoint?: boolean;
|
||||
deploymentId?: string;
|
||||
isFromAutoDetect?: boolean;
|
||||
}
|
||||
|
||||
// config.json
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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<string, string> = {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Vllm extends OpenAI {
|
|||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
|
||||
if (options.model === "AUTODETECT") {
|
||||
if (options.isFromAutoDetect) {
|
||||
this._setupCompletionOptions();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ interface Option {
|
|||
title: string;
|
||||
apiKey?: string;
|
||||
sourceFile?: string;
|
||||
isAutoDetected?: boolean;
|
||||
}
|
||||
|
||||
function modelSelectTitle(model: any): string {
|
||||
|
|
@ -75,6 +76,9 @@ function ModelOption({
|
|||
<CubeIcon className="h-3 w-3 flex-shrink-0" />
|
||||
<span className="line-clamp-1">
|
||||
{option.title}
|
||||
{option.isAutoDetected && (
|
||||
<span className="ml-2 text-[10px] italic">(autodetected)</span>
|
||||
)}
|
||||
{showMissingApiKeyMsg && (
|
||||
<span className="ml-2 text-[10px] italic">(Missing API key)</span>
|
||||
)}
|
||||
|
|
@ -132,6 +136,7 @@ function ModelSelect() {
|
|||
title: modelSelectTitle(model),
|
||||
apiKey: model.apiKey,
|
||||
sourceFile: model.sourceFile,
|
||||
isAutoDetected: model.isFromAutoDetect,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue