Add function to update configuration for version 0.9.12
- Added a new function `configUpdateTo_0912` to update the configuration for the 'devchat' extension. - The function retrieves the 'DevChat', 'Api_Key_OpenAI', and 'API_ENDPOINT' configurations and creates a new configuration object. - If the 'Model.gpt-4' configuration does not exist and the new configuration object is not empty, it updates the 'Model.gpt-3-5', 'Model.gpt-3-5-16k', and 'Model.gpt-4' configurations. - The function is called during the activation of the extension.
This commit is contained in:
parent
40803aa635
commit
dd1bef5539
@ -33,6 +33,43 @@ import { UiUtilWrapper } from './util/uiUtil';
|
||||
import { UiUtilVscode } from './util/uiUtil_vscode';
|
||||
import { FT } from './util/feature_flags/feature_toggles';
|
||||
|
||||
async function configUpdateTo_0912() {
|
||||
const devchatKey = UiUtilWrapper.getConfiguration('DevChat', 'Access_Key_DevChat');
|
||||
const openaiKey = UiUtilWrapper.getConfiguration('DevChat', 'Api_Key_OpenAI');
|
||||
const endpointKey = UiUtilWrapper.getConfiguration('DevChat', 'API_ENDPOINT');
|
||||
|
||||
let modelConfigNew = {};
|
||||
if (openaiKey) {
|
||||
modelConfigNew["api_key"] = openaiKey;
|
||||
} else if (devchatKey) {
|
||||
modelConfigNew["api_key"] = devchatKey;
|
||||
}
|
||||
|
||||
modelConfigNew["provider"] = "openai";
|
||||
|
||||
if (endpointKey) {
|
||||
modelConfigNew["api_base"] = endpointKey;
|
||||
}
|
||||
|
||||
const modelConfig1: any = UiUtilWrapper.getConfiguration("devchat", "Model.gpt-3-5");
|
||||
const modelConfig2: any = UiUtilWrapper.getConfiguration("devchat", "Model.gpt-3-5-16k");
|
||||
const modelConfig3: any = UiUtilWrapper.getConfiguration("devchat", "Model.gpt-4");
|
||||
//if (!modelConfig1 && !modelConfig2 && !modelConfig3 && Object.keys(modelConfigNew).length > 0) {
|
||||
if (Object.keys(modelConfig1).length === 0 &&
|
||||
Object.keys(modelConfig2).length === 0 &&
|
||||
Object.keys(modelConfig3).length === 0 &&
|
||||
Object.keys(modelConfigNew).length > 0) {
|
||||
// config default gpt models
|
||||
try {
|
||||
vscode.workspace.getConfiguration("devchat").update("Model.gpt-3-5", modelConfigNew, vscode.ConfigurationTarget.Global);
|
||||
vscode.workspace.getConfiguration("devchat").update("Model.gpt-3-5-16k", modelConfigNew, vscode.ConfigurationTarget.Global);
|
||||
vscode.workspace.getConfiguration("devchat").update("Model.gpt-4", modelConfigNew, vscode.ConfigurationTarget.Global);
|
||||
} catch(error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function activate(context: vscode.ExtensionContext) {
|
||||
ExtensionContextHolder.context = context;
|
||||
@ -40,6 +77,8 @@ function activate(context: vscode.ExtensionContext) {
|
||||
logger.init(LoggerChannelVscode.getInstance());
|
||||
UiUtilWrapper.init(new UiUtilVscode());
|
||||
|
||||
configUpdateTo_0912();
|
||||
|
||||
regLanguageContext();
|
||||
|
||||
regDevChatView(context);
|
||||
|
Loading…
x
Reference in New Issue
Block a user