From 2bd5d3ebf8f3a6d78f6b080b55b69df0ac838d14 Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Tue, 6 Feb 2024 11:31:44 +0800 Subject: [PATCH] feat: Implement model default parameter settings - Define model specific max_input_tokens to prevent overflow errors - Ensure default token limits are set for each model configuration - Integrate the default parameter setup within the activation process --- src/extension.ts | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index a3bdc3c..bb7ddbd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -272,6 +272,54 @@ async function updateInvalidDefaultModel() { // "gpt-3.5-turbo-1106", // "gpt-3.5-turbo-16k", +async function configSetModelDefaultParams() { + const modelParams = { + "Model.gpt-3-5": { + "max_input_tokens": 13000 + }, + "Model.gpt-4": { + "max_input_tokens": 6000 + }, + "Model.gpt-4-turbo": { + "max_input_tokens": 32000 + }, + "Model.claude-2": { + "max_input_tokens": 32000 + }, + "Model.xinghuo-2": { + "max_input_tokens": 6000 + }, + "Model.chatglm_pro": { + "max_input_tokens": 8000 + }, + "Model.ERNIE-Bot": { + "max_input_tokens": 8000 + }, + "Model.CodeLlama-70b": { + "max_input_tokens": 4000 + }, + "Model.Mixtral-8x7B": { + "max_input_tokens": 4000 + }, + "Model.Minimax-abab6": { + "max_input_tokens": 4000 + }, + "Model.llama-2-70b-chat": { + "max_input_tokens": 4000 + } + }; + + // set default params + for (const model of Object.keys(modelParams)) { + const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model); + if (!modelConfig["max_input_tokens"]) { + modelConfig["max_input_tokens"] = modelParams[model]["max_input_tokens"]; + await vscode.workspace.getConfiguration("devchat").update(model, modelConfig, vscode.ConfigurationTarget.Global); + + } + } +} + async function activate(context: vscode.ExtensionContext) { ExtensionContextHolder.context = context; @@ -285,6 +333,7 @@ async function activate(context: vscode.ExtensionContext) { await updateInvalidSettings(); await updateInvalidDefaultModel(); await configUpdateto240205(); + await configSetModelDefaultParams(); regLanguageContext();