🎨 pass ideSettings to llmFromDescription
This commit is contained in:
parent
fb2dca8155
commit
7d5dc4958a
4 changed files with 49 additions and 34 deletions
|
|
@ -29,7 +29,7 @@ export class ConfigHandler {
|
|||
}
|
||||
|
||||
updateIdeSettings(ideSettings: IdeSettings) {
|
||||
this.ideSettings = ideSettings
|
||||
this.ideSettings = ideSettings;
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
|
|
@ -63,19 +63,10 @@ export class ConfigHandler {
|
|||
const ideInfo = await this.ide.getIdeInfo();
|
||||
const uniqueId = await this.ide.getUniqueId();
|
||||
|
||||
let remoteConfigServerUrl = undefined;
|
||||
try {
|
||||
remoteConfigServerUrl =
|
||||
typeof this.ideSettings.remoteConfigServerUrl !== "string" ||
|
||||
this.ideSettings.remoteConfigServerUrl === ""
|
||||
? undefined
|
||||
: new URL(this.ideSettings.remoteConfigServerUrl);
|
||||
} catch (e) {}
|
||||
|
||||
this.savedConfig = await loadFullConfigNode(
|
||||
this.ide.readFile.bind(this.ide),
|
||||
workspaceConfigs,
|
||||
remoteConfigServerUrl,
|
||||
this.ideSettings,
|
||||
ideInfo.ideType,
|
||||
uniqueId,
|
||||
this.writeLog,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import { AllEmbeddingsProviders } from "../indexing/embeddings/index.js";
|
|||
import { BaseLLM } from "../llm/index.js";
|
||||
import CustomLLMClass from "../llm/llms/CustomLLM.js";
|
||||
import { llmFromDescription } from "../llm/llms/index.js";
|
||||
import { IdeSettings } from "../protocol.js";
|
||||
import { fetchwithRequestOptions } from "../util/fetchWithOptions.js";
|
||||
import { copyOf } from "../util/index.js";
|
||||
import mergeJson from "../util/merge.js";
|
||||
|
|
@ -81,7 +82,7 @@ const configMergeKeys = {
|
|||
|
||||
function loadSerializedConfig(
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
remoteConfigServerUrl: URL | undefined,
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
): SerializedContinueConfig {
|
||||
const configPath = getConfigJsonPath(ideType);
|
||||
|
|
@ -96,10 +97,10 @@ function loadSerializedConfig(
|
|||
config.allowAnonymousTelemetry = true;
|
||||
}
|
||||
|
||||
if (remoteConfigServerUrl) {
|
||||
if (ideSettings.remoteConfigServerUrl) {
|
||||
try {
|
||||
const remoteConfigJson = resolveSerializedConfig(
|
||||
getConfigJsonPathForRemote(remoteConfigServerUrl),
|
||||
getConfigJsonPathForRemote(ideSettings.remoteConfigServerUrl),
|
||||
);
|
||||
config = mergeJson(config, remoteConfigJson, "merge", configMergeKeys);
|
||||
} catch (e) {
|
||||
|
|
@ -168,6 +169,7 @@ function isContextProviderWithParams(
|
|||
async function intermediateToFinalConfig(
|
||||
config: Config,
|
||||
readFile: (filepath: string) => Promise<string>,
|
||||
ideSettings: IdeSettings,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
): Promise<ContinueConfig> {
|
||||
|
|
@ -179,11 +181,14 @@ async function intermediateToFinalConfig(
|
|||
desc,
|
||||
readFile,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
config.completionOptions,
|
||||
config.systemMessage,
|
||||
);
|
||||
if (!llm) {continue;}
|
||||
if (!llm) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (llm.model === "AUTODETECT") {
|
||||
try {
|
||||
|
|
@ -198,6 +203,7 @@ async function intermediateToFinalConfig(
|
|||
},
|
||||
readFile,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
copyOf(config.completionOptions),
|
||||
config.systemMessage,
|
||||
|
|
@ -257,6 +263,7 @@ async function intermediateToFinalConfig(
|
|||
config.tabAutocompleteModel,
|
||||
readFile,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
config.completionOptions,
|
||||
config.systemMessage,
|
||||
|
|
@ -446,16 +453,12 @@ async function buildConfigTs() {
|
|||
async function loadFullConfigNode(
|
||||
readFile: (filepath: string) => Promise<string>,
|
||||
workspaceConfigs: ContinueRcJson[],
|
||||
remoteConfigServerUrl: URL | undefined,
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
): Promise<ContinueConfig> {
|
||||
let serialized = loadSerializedConfig(
|
||||
workspaceConfigs,
|
||||
remoteConfigServerUrl,
|
||||
ideType,
|
||||
);
|
||||
let serialized = loadSerializedConfig(workspaceConfigs, ideSettings, ideType);
|
||||
let intermediate = serializedToIntermediateConfig(serialized);
|
||||
|
||||
const configJsContents = await buildConfigTs();
|
||||
|
|
@ -475,10 +478,10 @@ async function loadFullConfigNode(
|
|||
}
|
||||
|
||||
// Remote config.js
|
||||
if (remoteConfigServerUrl) {
|
||||
if (ideSettings.remoteConfigServerUrl) {
|
||||
try {
|
||||
const configJsPathForRemote = getConfigJsPathForRemote(
|
||||
remoteConfigServerUrl,
|
||||
ideSettings.remoteConfigServerUrl,
|
||||
);
|
||||
const module = await require(configJsPathForRemote);
|
||||
delete require.cache[require.resolve(configJsPathForRemote)];
|
||||
|
|
@ -494,6 +497,7 @@ async function loadFullConfigNode(
|
|||
const finalConfig = await intermediateToFinalConfig(
|
||||
intermediate,
|
||||
readFile,
|
||||
ideSettings,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
);
|
||||
|
|
@ -505,6 +509,5 @@ export {
|
|||
intermediateToFinalConfig,
|
||||
loadFullConfigNode,
|
||||
serializedToIntermediateConfig,
|
||||
type BrowserSerializedContinueConfig
|
||||
type BrowserSerializedContinueConfig,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
LLMOptions,
|
||||
ModelDescription,
|
||||
} from "../../index.js";
|
||||
import { IdeSettings } from "../../protocol.js";
|
||||
import { DEFAULT_MAX_TOKENS } from "../constants.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
import Anthropic from "./Anthropic.js";
|
||||
|
|
@ -104,6 +105,7 @@ export async function llmFromDescription(
|
|||
desc: ModelDescription,
|
||||
readFile: (filepath: string) => Promise<string>,
|
||||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
completionOptions?: BaseCompletionOptions,
|
||||
systemMessage?: string,
|
||||
|
|
@ -124,7 +126,7 @@ export async function llmFromDescription(
|
|||
systemMessage = await renderTemplatedString(systemMessage, readFile, {});
|
||||
}
|
||||
|
||||
const options: LLMOptions = {
|
||||
let options: LLMOptions = {
|
||||
...desc,
|
||||
completionOptions: {
|
||||
...finalCompletionOptions,
|
||||
|
|
@ -139,6 +141,17 @@ export async function llmFromDescription(
|
|||
uniqueId,
|
||||
};
|
||||
|
||||
if (desc.provider === "continue-proxy") {
|
||||
options = {
|
||||
...options,
|
||||
apiBase: new URL(
|
||||
"/proxy/v1",
|
||||
ideSettings.remoteConfigServerUrl,
|
||||
).toString(),
|
||||
apiKey: ideSettings.userToken,
|
||||
};
|
||||
}
|
||||
|
||||
return new cls(options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import dotenv from "dotenv";
|
|||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { IdeType, SerializedContinueConfig } from "../index.js";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default.js";
|
||||
import Types from "../config/types.js";
|
||||
import { IdeType, SerializedContinueConfig } from "../index.js";
|
||||
|
||||
export function getContinueGlobalPath(): string {
|
||||
// This is ~/.continue on mac/linux
|
||||
|
|
@ -197,22 +197,30 @@ export function getRemoteConfigsFolderPath(): string {
|
|||
return dir;
|
||||
}
|
||||
|
||||
export function getPathToRemoteConfig(remoteConfigServerUrl: URL): string {
|
||||
const dir = path.join(
|
||||
getRemoteConfigsFolderPath(),
|
||||
remoteConfigServerUrl.hostname,
|
||||
);
|
||||
export function getPathToRemoteConfig(remoteConfigServerUrl: string): string {
|
||||
let url: URL | undefined = undefined;
|
||||
try {
|
||||
url =
|
||||
typeof remoteConfigServerUrl !== "string" || remoteConfigServerUrl === ""
|
||||
? undefined
|
||||
: new URL(remoteConfigServerUrl);
|
||||
} catch (e) {}
|
||||
const dir = path.join(getRemoteConfigsFolderPath(), url?.hostname ?? "None");
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
export function getConfigJsonPathForRemote(remoteConfigServerUrl: URL): string {
|
||||
export function getConfigJsonPathForRemote(
|
||||
remoteConfigServerUrl: string,
|
||||
): string {
|
||||
return path.join(getPathToRemoteConfig(remoteConfigServerUrl), "config.json");
|
||||
}
|
||||
|
||||
export function getConfigJsPathForRemote(remoteConfigServerUrl: URL): string {
|
||||
export function getConfigJsPathForRemote(
|
||||
remoteConfigServerUrl: string,
|
||||
): string {
|
||||
return path.join(getPathToRemoteConfig(remoteConfigServerUrl), "config.js");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue