diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d8df21..40bb458 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Change Log
+v1.0.9 (2022-12-12)
+
+- Fix some known bugs
+
+- Add survey component and will push the survey to some users
+
+- Add local display support when display language is configured as Chinese
+
+- Add conditions to keybindings to avoid conflict
+
+v1.0.8 (2022-12-05)
+
+- Fix bugs when using in jupyter notebook
+
+- If current language is disabled but it's globally enabled, the logo will also change color disabled
+
+- Enable or disable stealth mode will be memorized
+
v1.0.7 (2022-11-28)
- Add status bar command and user setting to disable specific languages
diff --git a/README.md b/README.md
index b43fd2e..af099ce 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,20 @@
![codegeex_logo](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/codegeex_logo.png)
-🌐 中文
+🌐 中文
![CodeGeeX license](https://img.shields.io/github/license/THUDM/CodeGeeX?colorA=0B9FE0&colorB=brightgreen)
![CodeGeeX vscode extension version](https://img.shields.io/visual-studio-marketplace/v/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
![CodeGeeX download](https://img.shields.io/visual-studio-marketplace/d/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
+![CodeGeeX API calls per week](https://img.shields.io/badge/dynamic/json?label=API%20calls&query=%24.result.count&suffix=%2Fweek&url=http%3A%2F%2Ftianqi.aminer.cn%2Fapi%2Fv1%2Fapi%2Fcodegeex%2Fdashboard%3Ftime_type%3Dweeks&colorA=0B9FE0&colorB=brightgreen)
![CodeGeeX vscode extension rating](https://img.shields.io/visual-studio-marketplace/stars/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
![CodeGeeX vscode extension last update](https://img.shields.io/visual-studio-marketplace/last-updated/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
[![CodeGeeX github stars](https://img.shields.io/github/stars/THUDM/CodeGeeX?style=social)](https://github.com/THUDM/CodeGeeX)
-We introduce CodeGeeX, an open source large-scale multilingual code generation model with 13 billion parameters, pretrained on a large code corpus of more than 20 programming languages. With CodeGeeX, we create an extension that can generate codes by only providing natural language descriptions, complete any code snippet, or translate codes to other programming languages, etc. CodeGeeX also provides customizable features (**Prompt Mode**) to help you configure your own programming assistant. Happy coding!
+We introduce CodeGeeX, a open source large-scale multilingual code generation model with 13 billion parameters, pretrained on a large code corpus of more than 20 programming languages. With CodeGeeX, we can generate codes by only providing natural language descriptions, complete any code snippet, or translate codes to other programming languages, etc. CodeGeeX also provides customizable features (**Prompt Mode**) to help you configure your own programming assistant. Happy coding!
For more information, please check out our [Homepage](https://models.aminer.cn/codegeex/) and [GitHub repo](https://github.com/THUDM/CodeGeeX).
-Please kindly let us know if you encounter any problem or have any suggestion, via [codegeex@aminer.cn](mailto:codegeex@aminer.cn).
-
-## Extension Development
-CodeGeeX extension is fully open sourced and welcome to add new features to it. A simple developpment guidance can be found in [doc/quickstart.md](doc/quickstart.md).
+Please kindly let us know if you encounter any problem or have any suggestion, via [codegeex@aminer.cn](mailto:codegeex@aminer.cn). Or you can also fill the survey to tell us about all your feelings for our extension[EN](https://wj.qq.com/s2/11260705/6cd6/)[CN](https://wj.qq.com/s2/11259178/fd49/).
## Basic Usage
Make sure vscode version is >= 1.68.0. Install the extension and enable it globally. There are three modes of usage:
diff --git a/README_zh.md b/README_zh.md
index a91ab93..b51e232 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -1,21 +1,11 @@
![codegeex_logo](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/codegeex_logo.png)
-![CodeGeeX license](https://img.shields.io/github/license/THUDM/CodeGeeX?colorA=0B9FE0&colorB=brightgreen)
-![CodeGeeX vscode extension version](https://img.shields.io/visual-studio-marketplace/v/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
-![CodeGeeX download](https://img.shields.io/visual-studio-marketplace/d/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
-![CodeGeeX vscode extension rating](https://img.shields.io/visual-studio-marketplace/stars/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
-![CodeGeeX vscode extension last update](https://img.shields.io/visual-studio-marketplace/last-updated/aminer.codegeex?colorA=0B9FE0&colorB=brightgreen)
-[![CodeGeeX github stars](https://img.shields.io/github/stars/THUDM/CodeGeeX?style=social)](https://github.com/THUDM/CodeGeeX)
-
CodeGeeX是一个具有130亿参数的多编程语言代码生成预训练模型,使用超过二十种编程语言训练得到。基于CodeGeeX开发的插件可以实现通过描述生成代码、补全代码、代码翻译等一系列功能。CodeGeeX同样提供可以定制的**提示模式(Prompt Mode)**,构建专属的编程助手。Happy Coding!
VS Code插件市场搜索"codegeex"即可免费使用,更多关于CodeGeeX信息请见我们的[主页](https://models.aminer.cn/codegeex/) and [GitHub仓库](https://github.com/THUDM/CodeGeeX)。
如使用过程中遇到问题或有任何改进意见,欢迎发送邮件到[codegeex@aminer.cn](mailto:codegeex@aminer.cn)反馈!
-## 插件开发
-CodeGeeX是完全开源的,欢迎开发者们为插件添加新功能,[doc/quickstart_zh.md](doc/quickstart_zh.md)中可以找到简单的开发调试教程。
-
## 基本用法
安装插件并全局激活CodeGeeX,有以下三种使用模式:
diff --git a/package.json b/package.json
index be36935..cd5c375 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
"url": "https://github.com/THUDM/CodeGeeX"
},
"icon": "codegeex_logo.png",
- "version": "1.0.8",
+ "version": "1.0.9",
"engines": {
"vscode": "^1.68.0"
},
@@ -118,7 +118,20 @@
},
"Codegeex.EnableExtension":{
"type":"boolean",
- "default":true
+ "default":true,
+ "description": "This will decide if you enable the stealth mode of the extension."
+ },
+ "Codegeex.Survey":{
+ "type":"boolean",
+ "default":null,
+ "markdownDescription": "This is decided by if you have chosen to make a survey. If you want to make the survey again, you can click the link:
[EN]:https://wj.qq.com/s2/11260705/6cd6/
[CN]:https://wj.qq.com/s2/11259178/fd49/"
+ },
+ "Codegeex.CompletionDelay":{
+ "type":"number",
+ "minimum": 0.5,
+ "default":0.5,
+ "description": "The delay in seconds to start getting completions without new change in the editor. You can change this value to get better experience in coding with our extension and to avoid some unuseful completion suggestions."
+
}
}
}
@@ -127,19 +140,23 @@
{
"command": "codegeex.interactive-mode",
"key": "ctrl+enter",
- "mac": "ctrl+enter"
+ "mac": "ctrl+enter",
+ "when":"editorFocus && !editorReadonly"
},
{
"command": "codegeex.prompt-mode",
- "key": "Alt+T"
+ "key": "Alt+T",
+ "when":"editorFocus && !editorReadonly"
},
{
"command": "codegeex.new-completions",
- "key": "Alt+N"
+ "key": "Alt+N",
+ "when":"editorFocus && !editorReadonly"
},
{
"command": "codegeex.translate-mode",
- "key": "Alt+ctrl+T"
+ "key": "Alt+ctrl+T",
+ "when":"editorFocus && !editorReadonly"
},
{
"command": "codegeex.welcome-page",
diff --git a/src/disableEnable.ts b/src/disableEnable.ts
index 605f57b..95edc44 100644
--- a/src/disableEnable.ts
+++ b/src/disableEnable.ts
@@ -1,5 +1,6 @@
import * as vscode from "vscode";
import { disabledFor, enableExtension } from "./param/configures";
+import { localeTag } from "./param/constparams";
import changeIconColor from "./utils/changeIconColor";
import { updateStatusBarItem } from "./utils/updateStatusBarItem";
@@ -9,18 +10,18 @@ export default async function disableEnable(
g_isLoading: boolean,
originalColor: string | vscode.ThemeColor | undefined
) {
+ const lang = vscode.window.activeTextEditor?.document.languageId || "";
if (g_isEnable) {
- const lang = vscode.window.activeTextEditor?.document.languageId || "";
if (
(disabledFor as any)[lang] ||
(disabledFor as any)[lang] === "true"
) {
const answer = await vscode.window.showInformationMessage(
- "Would you like to disable CodeGeeX?",
- "Disable Globally",
- `Enable for ${lang}`
+ localeTag.disableInfo,
+ localeTag.disableGlobally,
+ `${localeTag.enable} ${lang}`
);
- if (answer === "Disable Globally") {
+ if (answer === localeTag.disableGlobally) {
// Run function
changeIconColor(false, myStatusBarItem, originalColor);
g_isEnable = false;
@@ -29,9 +30,8 @@ export default async function disableEnable(
undefined
);
configuration.update("EnableExtension", false);
- console.log(configuration);
}
- if (answer === `Enable for ${lang}`) {
+ if (answer === `${localeTag.enable} ${lang}`) {
// Run function
const configuration = vscode.workspace.getConfiguration(
"Codegeex",
@@ -39,15 +39,16 @@ export default async function disableEnable(
);
(disabledFor as any)[lang] = false;
configuration.update("DisabledFor", disabledFor);
+ changeIconColor(true, myStatusBarItem, originalColor);
}
} else {
const answer = await vscode.window.showInformationMessage(
- "Would you like to disable CodeGeeX?",
- "Disable Globally",
- `Disable for ${lang}`
+ localeTag.disableInfo,
+ localeTag.disableGlobally,
+ `${localeTag.disable} ${lang}`
);
- if (answer === "Disable Globally") {
+ if (answer === localeTag.disableGlobally) {
// Run function
changeIconColor(false, myStatusBarItem, originalColor);
const configuration = vscode.workspace.getConfiguration(
@@ -57,7 +58,7 @@ export default async function disableEnable(
g_isEnable = false;
configuration.update("EnableExtension", false);
}
- if (answer === `Disable for ${lang}`) {
+ if (answer === `${localeTag.disable} ${lang}`) {
// Run function
const configuration = vscode.workspace.getConfiguration(
"Codegeex",
@@ -66,16 +67,27 @@ export default async function disableEnable(
(disabledFor as any)[lang] = true;
configuration.update("DisabledFor", disabledFor);
updateStatusBarItem(myStatusBarItem, g_isLoading, false, "");
+ changeIconColor(true, myStatusBarItem, originalColor,true);
+
}
}
} else {
const answer = await vscode.window.showInformationMessage(
- "Would you like to enable CodeGeeX?",
- "Enable Globally"
+ localeTag.enableInfo,
+ localeTag.enableGlobally
);
- if (answer === "Enable Globally") {
+ if (answer === localeTag.enableGlobally) {
// Run function
- changeIconColor(true, myStatusBarItem, originalColor);
+ if (
+ (disabledFor as any)[lang] ||
+ (disabledFor as any)[lang] === "true"
+ ){
+ changeIconColor(true, myStatusBarItem, originalColor,true);
+
+ }else{
+
+ changeIconColor(true, myStatusBarItem, originalColor);
+ }
const configuration = vscode.workspace.getConfiguration(
"Codegeex",
undefined
diff --git a/src/extension.ts b/src/extension.ts
index c36f4fc..e75e7de 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -1,8 +1,8 @@
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
import * as vscode from "vscode";
-import { myScheme } from "./param/constparams";
+import { localeTag, myScheme } from "./param/constparams";
import { checkPrivacy } from "./utils/checkPrivacy";
-import { getEndData, getOpenExtensionData } from "./utils/statisticFunc";
+import { getEndData, getOpenExtensionData, getTotalRequestNum } from "./utils/statisticFunc";
import { updateStatusBarItem } from "./utils/updateStatusBarItem";
import { generateWithPromptMode } from "./mode/generationWithPrompMode";
import welcomePage from "./welcomePage";
@@ -15,6 +15,8 @@ import { textDocumentProvider } from "./provider/textDocumentProvider";
import inlineCompletionProvider from "./provider/inlineCompletionProvider";
import { enableExtension } from "./param/configures";
import changeIconColor from "./utils/changeIconColor";
+import { isCurrentLanguageDisable } from "./utils/isCurrentLanguageDisable";
+import survey from "./utils/survey";
let g_isLoading = false;
let originalColor: string | vscode.ThemeColor | undefined;
@@ -22,9 +24,10 @@ let myStatusBarItem: vscode.StatusBarItem;
export async function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "CodeGeeX" is now active!');
- try {
+ try{
+
await getOpenExtensionData();
- } catch (err) {
+ }catch(err){
console.error(err);
}
context.subscriptions.push(
@@ -36,6 +39,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand("codegeex.welcome-page");
}
checkPrivacy();
+ survey();
let targetEditor: vscode.TextEditor;
const statusBarItemCommandId = "codegeex.disable-enable";
@@ -52,9 +56,8 @@ export async function activate(context: vscode.ExtensionContext) {
myStatusBarItem.command = statusBarItemCommandId;
context.subscriptions.push(myStatusBarItem);
//initialiser statusbar
- changeIconColor(enableExtension, myStatusBarItem, originalColor);
+ changeIconColor(enableExtension, myStatusBarItem, originalColor,isCurrentLanguageDisable());
updateStatusBarItem(myStatusBarItem, g_isLoading, false, "");
-
//subscribe interactive-mode command
context.subscriptions.push(
vscode.commands.registerCommand(
@@ -63,7 +66,7 @@ export async function activate(context: vscode.ExtensionContext) {
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showInformationMessage(
- "Please open a file first to use CodeGeeX."
+ localeTag.noEditorInfo
);
return;
}
@@ -82,7 +85,7 @@ export async function activate(context: vscode.ExtensionContext) {
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showInformationMessage(
- "Please open a file first to use CodeGeeX translation."
+ localeTag.noEditorInfo
);
return;
}
@@ -99,7 +102,7 @@ export async function activate(context: vscode.ExtensionContext) {
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showInformationMessage(
- "Please open a file first to use CodeGeeX translation."
+ localeTag.noEditorInfo
);
return;
}
@@ -109,7 +112,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
myScheme,
- textDocumentProvider(myStatusBarItem, g_isLoading)
+ textDocumentProvider(myStatusBarItem,g_isLoading)
)
);
context.subscriptions.push(
@@ -128,15 +131,17 @@ export async function activate(context: vscode.ExtensionContext) {
)
);
+
//command after insert a suggestion in stealth mode
context.subscriptions.push(
vscode.commands.registerCommand(
"verifyInsertion",
async (id, completions, acceptItem) => {
- try {
+ try{
+
await getEndData(id, "", "Yes", acceptItem, completions);
- } catch (err) {
- console.log(err);
+ }catch(err){
+ console.log(err)
}
}
)
@@ -144,16 +149,24 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.languages.registerInlineCompletionItemProvider(
{ pattern: "**" },
- inlineCompletionProvider(g_isLoading, myStatusBarItem, false)
+ inlineCompletionProvider(g_isLoading, myStatusBarItem, false,originalColor)
)
);
context.subscriptions.push(
vscode.commands.registerCommand("codegeex.new-completions", () => {
vscode.languages.registerInlineCompletionItemProvider(
{ pattern: "**" },
- inlineCompletionProvider(g_isLoading, myStatusBarItem, true)
+ inlineCompletionProvider(g_isLoading, myStatusBarItem, true,originalColor)
);
})
);
+ context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(e=>{
+ const editor = vscode.window.activeTextEditor;
+ if(editor){
+ changeIconColor(true,myStatusBarItem,originalColor,isCurrentLanguageDisable(),true)
+
+ }
+ }))
+
}
export function deactivate() {}
diff --git a/src/locales/localeCN.ts b/src/locales/localeCN.ts
new file mode 100644
index 0000000..a963988
--- /dev/null
+++ b/src/locales/localeCN.ts
@@ -0,0 +1,26 @@
+export const localeCN = {
+ useCode:'使用代码',
+ chooseThisSnippet:'选择这个代码片段',
+ noEditorInfo: '请先打开一个文件来使用CodeGeeX。',
+ generating:'CodeGeeX生成中...',
+ noResult:'没有结果',
+ sendingRequestErr:'请求出错',
+ privacyInfo:"我们十分尊重您的隐私,您同意只为了研究目的分享您生成的代码使CodeGeeX变得更好么?反之,代码将不会被储存并只会用于协助您进行编程。",
+ privacyAccept:'同意',
+ privacyDecline:'拒绝',
+ errorInInputMarkup:'标签里面存在错误',
+ candidateList:'由CodeGeeX生成的候选列表',
+ surveyInfo:'您已经使用CodeGeeX一段时间了,您想和我们分享您的使用体验吗?',
+ surveyYes:'是',
+ surveyNo:'否',
+ disableInfo:'您想禁用CodeGeeX吗?',
+ disableGlobally:'全局禁用',
+ disable:'禁用',
+ enable:'启用',
+ enableInfo:'您想启用CodeGeeX吗?',
+ enableGlobally:'全局启用',
+ chooseLanguage:'请选择被翻译代码的语言。',
+ languageNotSupported:'对不起,目标语言目前尚不支持。',
+ selectCode:'请选择要被翻译的代码。'
+
+}
\ No newline at end of file
diff --git a/src/locales/localeEN.ts b/src/locales/localeEN.ts
new file mode 100644
index 0000000..622d512
--- /dev/null
+++ b/src/locales/localeEN.ts
@@ -0,0 +1,25 @@
+export const localeEN = {
+ useCode:'Use Code',
+ chooseThisSnippet:'Choose This Snippet',
+ noEditorInfo: 'Please open a file first to use CodeGeeX.',
+ generating:'CodeGeeX is generating ...',
+ noResult:'No result to show',
+ sendingRequestErr:'There was an error sending the request',
+ privacyInfo:"We highly respect the privacy of your code. Do you accept sharing the generated code only for research purposes to make CodeGeeX better? Otherwise, the code won't be stored and is only used to assist your programming.",
+ privacyAccept:'Accept',
+ privacyDecline:'Decline',
+ errorInInputMarkup:'There is an error in markup.',
+ candidateList:'The candidate list of code generated by CodeGeeX',
+ surveyInfo:'You have used our extension for a while, would you like to tell us about everything you feel about our extension?',
+ surveyYes:'Yes',
+ surveyNo:'No',
+ disableInfo:'Would you like to disable CodeGeeX?',
+ disableGlobally:'Disable Globally',
+ disable:'disable',
+ enable:'enable',
+ enableInfo:'Would you like to enable CodeGeeX?',
+ enableGlobally:'Enable Globally',
+ chooseLanguage:'Please choose the language to be translated.',
+ languageNotSupported:'Sorry, the target language is not supported.',
+ selectCode:'Please select some code to be translated.'
+}
\ No newline at end of file
diff --git a/src/mode/generationWithInteractiveMode.ts b/src/mode/generationWithInteractiveMode.ts
index f02aa0a..65b0d9e 100644
--- a/src/mode/generationWithInteractiveMode.ts
+++ b/src/mode/generationWithInteractiveMode.ts
@@ -26,7 +26,6 @@ export default async function generationWithInteractiveMode(
.replaceAll("#", hash)
.replaceAll("+", addSignal)
.replaceAll("&", andSignal);
- console.log("code_block", code_block);
updateStatusBarItem(myStatusBarItem, g_isLoading, true, "");
await codegeexCodeGen(code_block.trim())
.then(() =>
diff --git a/src/mode/generationWithTranslationMode.ts b/src/mode/generationWithTranslationMode.ts
index 0f44711..a175fa4 100644
--- a/src/mode/generationWithTranslationMode.ts
+++ b/src/mode/generationWithTranslationMode.ts
@@ -1,6 +1,7 @@
import * as vscode from "vscode";
-import { hash, languageList } from "../param/constparams";
+import { hash, languageList, localeTag } from "../param/constparams";
import { codegeexCodeTranslation } from "../utils/codegeexCodeTranslation";
+import { getCommentSignal } from "../utils/commentCode";
import { getCodeTranslation } from "../utils/getCodeTranslation";
import getDocumentLanguage from "../utils/getDocumentLanguage";
import { showQuickPick } from "../utils/showQuickPick";
@@ -26,7 +27,7 @@ export default async function generationWithTranslationMode(
let srcLang =
(await showQuickPick(
languageList,
- "Please choose the language to be translated."
+ localeTag.chooseLanguage
)) || "";
let translation;
if (
@@ -39,7 +40,7 @@ export default async function generationWithTranslationMode(
true,
" Translating"
);
- let commandid: string;
+ let commandid:string;
try{
commandid = await getStartData(
@@ -49,7 +50,7 @@ export default async function generationWithTranslationMode(
"translation"
);
}catch(err){
- commandid=''
+ commandid='';
}
translation = await getCodeTranslation(text, srcLang, dstLang).then(
async (res) => {
@@ -70,17 +71,17 @@ export default async function generationWithTranslationMode(
}
if (languageList.indexOf(srcLang) < 0) {
vscode.window.showInformationMessage(
- "Please choose the language to be translated."
+ localeTag.chooseLanguage
);
}
if (languageList.indexOf(dstLang) < 0) {
vscode.window.showInformationMessage(
- "Sorry, the target language is not supported."
+ localeTag.languageNotSupported
);
}
} else {
vscode.window.showInformationMessage(
- "Please select some code to be translated"
+ localeTag.selectCode
);
}
}
diff --git a/src/param/configures.ts b/src/param/configures.ts
index d80d247..81c542e 100644
--- a/src/param/configures.ts
+++ b/src/param/configures.ts
@@ -1,7 +1,6 @@
import { workspace } from "vscode";
const configuration = workspace.getConfiguration("Codegeex", undefined);
-console.log(configuration);
export const generationPreference = configuration.get("GenerationPreference");
export const disabledFor = configuration.get("DisabledFor", new Object());
@@ -37,6 +36,8 @@ export const candidateNum = parseInt(candidateNum_str);
export const needGuide = configuration.get("NeedGuide");
export const translationInsertMode = configuration.get("Translation");
export const enableExtension = configuration.get("EnableExtension", true);
+export const acceptedsurvey = configuration.get("Survey",null);
+export const completionDelay = configuration.get('CompletionDelay',0.5);
export const controls = {
interactiveMode: {
mac: "Control + Enter",
diff --git a/src/param/constparams.ts b/src/param/constparams.ts
index b69606e..78a7fcd 100644
--- a/src/param/constparams.ts
+++ b/src/param/constparams.ts
@@ -1,7 +1,10 @@
-import { tianqiApiKey, tianqiApiSecret,statsHerf } from "../localconfig";
+import { tianqiApiKey, tianqiApiSecret, statApiHerf, surveyUrlCN, surveyUrlEN } from "../localconfig";
+import * as vscode from 'vscode';
+import { localeCN } from "../locales/localeCN";
+import { localeEN } from "../locales/localeEN";
export const extensionId = "aminer.codegeex";
-export const extensionVersion = "1.0.7";
+export const extensionVersion = "1.0.9";
export const myScheme = "codegeex";
//configure the key and Secret of tianqi
@@ -9,7 +12,7 @@ export const apiKey = tianqiApiKey;
export const apiSecret = tianqiApiSecret;
//api to do the statistics of data
-export const apiHerf = statsHerf;
+export const apiHerf = statApiHerf;
//language accepted by the model
export const languageList = [
@@ -39,3 +42,9 @@ export const comment = "<|comment|>";
export const addSignal = "<|add|>";
export const andSignal = "<|and|>";
export const hash = "<|hash|>";
+
+//locale language
+export const locale = vscode.env.language;
+
+export const surveyUrl = locale === 'zh-cn'? surveyUrlCN:surveyUrlEN;
+export const localeTag = locale === 'zh-cn'? localeCN:localeEN;
\ No newline at end of file
diff --git a/src/provider/codelensProvider.ts b/src/provider/codelensProvider.ts
index 510e0e8..ef9ff26 100644
--- a/src/provider/codelensProvider.ts
+++ b/src/provider/codelensProvider.ts
@@ -1,4 +1,5 @@
import * as vscode from "vscode";
+import { localeTag } from "../param/constparams";
export const codelensProvider = new (class {
codelenses: vscode.CodeLens[];
@@ -7,19 +8,17 @@ export const codelensProvider = new (class {
}
addEl(lineNum: number, text: string, commandid: string, mode?: string) {
let range;
- console.log(text[0] === "\n");
range = new vscode.Range(lineNum, 0, lineNum, 0);
this.codelenses.push(
new vscode.CodeLens(range, {
- title: "Use code",
+ title: localeTag.useCode,
command: "CodeGeeX.chooseCandidate",
arguments: [text, mode, commandid],
- tooltip: "Choose this snippet",
+ tooltip: localeTag.chooseThisSnippet,
})
);
- console.log(this.codelenses);
}
clearEls() {
this.codelenses = [];
diff --git a/src/provider/inlineCompletionProvider.ts b/src/provider/inlineCompletionProvider.ts
index e0ec8d1..54204e2 100644
--- a/src/provider/inlineCompletionProvider.ts
+++ b/src/provider/inlineCompletionProvider.ts
@@ -1,5 +1,5 @@
import * as vscode from "vscode";
-import { candidateNum, disabledFor } from "../param/configures";
+import { candidateNum, completionDelay, disabledFor } from "../param/configures";
import { apiKey, apiSecret } from "../param/constparams";
import { Trie } from "../trie";
import { getCodeCompletions } from "../utils/getCodeCompletions";
@@ -10,6 +10,7 @@ let lastRequest = null;
let trie = new Trie([]);
let prompts: string[] = [];
let someTrackingIdCounter = 0;
+let delay:number=completionDelay*1000;
interface MyInlineCompletionItem extends vscode.InlineCompletionItem {
trackingId: number;
@@ -17,7 +18,8 @@ interface MyInlineCompletionItem extends vscode.InlineCompletionItem {
export default function inlineCompletionProvider(
g_isLoading: boolean,
myStatusBarItem: vscode.StatusBarItem,
- reGetCompletions: boolean
+ reGetCompletions: boolean,
+ originalColor: string | vscode.ThemeColor | undefined,
) {
const provider: vscode.InlineCompletionItemProvider = {
provideInlineCompletionItems: async (
@@ -42,10 +44,6 @@ export default function inlineCompletionProvider(
}
let selection: vscode.Selection;
const languageId = editor.document.languageId || "undefined";
- console.log(disabledFor);
- console.log(
- vscode.workspace.getConfiguration("Codegeex.DisabledFor")
- );
if (
(disabledFor as any)[languageId] === true ||
(disabledFor as any)[languageId] === "true" ||
@@ -68,10 +66,8 @@ export default function inlineCompletionProvider(
for(let i = 0;i();
let lastLine = document.lineAt(document.lineCount - 1);
for (
@@ -149,7 +137,6 @@ export default function inlineCompletionProvider(
while (lines[nonNullIndex].trim() === "") {
nonNullIndex++;
}
- console.log(nonNullIndex);
let newInsertText = "";
for (
let j = nonNullIndex;
@@ -161,7 +148,6 @@ export default function inlineCompletionProvider(
newInsertText += "\n";
}
}
- console.log(newInsertText);
if (
textBeforeCursor[
textBeforeCursor.length - 1
@@ -209,7 +195,7 @@ export default function inlineCompletionProvider(
console.log("try to get");
let requestId = new Date().getTime();
lastRequest = requestId;
- await new Promise((f) => setTimeout(f, 500));
+ await new Promise((f) => setTimeout(f, delay));
if (lastRequest !== requestId) {
return { items: [] };
}
@@ -228,6 +214,7 @@ export default function inlineCompletionProvider(
lang = getDocumentLanguage(editor);
}
updateStatusBarItem(myStatusBarItem, g_isLoading, true, "");
+ let timestart= new Date().getTime();
rs = await getCodeCompletions(
textBeforeCursor,
num,
@@ -236,6 +223,8 @@ export default function inlineCompletionProvider(
apiSecret,
"inlinecompletion"
);
+ let timeend = new Date().getTime();
+ console.log('time execute',timeend-timestart)
} catch (err) {
if (err) {
console.log("intended error");
@@ -263,8 +252,6 @@ export default function inlineCompletionProvider(
let items = new Array();
let cursorPosition = editor.selection.active;
for (let i = 0; i < rs.completions.length; i++) {
- //rs.completions[i].replace('from\'','from \'')
- console.log("test", rs.completions[i]);
items.push({
insertText: rs.completions[i],
// range: new vscode.Range(endPosition.translate(0, rs.completions.length), endPosition),
diff --git a/src/provider/textDocumentProvider.ts b/src/provider/textDocumentProvider.ts
index c60808d..ff6ff25 100644
--- a/src/provider/textDocumentProvider.ts
+++ b/src/provider/textDocumentProvider.ts
@@ -10,6 +10,7 @@ import {
apiSecret,
comment,
hash,
+ localeTag,
} from "../param/constparams";
import { getCommentSignal } from "../utils/commentCode";
import getDocumentLanguage from "../utils/getDocumentLanguage";
@@ -21,7 +22,7 @@ export function textDocumentProvider(myStatusBarItem: vscode.StatusBarItem, g_is
async provideTextDocumentContent(uri: vscode.Uri) {
const params = new URLSearchParams(uri.query);
if (params.get("loading") === "true") {
- return `/* CodeGeeX is generating ... */\n`;
+ return `/* ${localeTag.generating} */\n`;
}
const mode = params.get("mode");
@@ -30,11 +31,10 @@ export function textDocumentProvider(myStatusBarItem: vscode.StatusBarItem, g_is
transResult = transResult
.replaceAll(addSignal, "+")
.replaceAll(andSignal, "&");
- console.log("transResult", transResult);
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showInformationMessage(
- "Please open a file first to use CodeGeeX."
+ localeTag.noEditorInfo
);
return;
}
@@ -61,7 +61,7 @@ export function textDocumentProvider(myStatusBarItem: vscode.StatusBarItem, g_is
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showInformationMessage(
- "Please open a file first to use CodeGeeX."
+ localeTag.noEditorInfo
);
return;
}
@@ -104,11 +104,11 @@ export function textDocumentProvider(myStatusBarItem: vscode.StatusBarItem, g_is
g_isLoading
);
} else {
- return "No result to show";
+ return localeTag.noResult;
}
} catch (err) {
console.log("Error sending request", err);
- return "There was an error sending the request\n" + err;
+ return `${localeTag.sendingRequestErr}\n` + err;
}
}
}
diff --git a/src/utils/changeIconColor.ts b/src/utils/changeIconColor.ts
index 090bacb..3cd5a0e 100644
--- a/src/utils/changeIconColor.ts
+++ b/src/utils/changeIconColor.ts
@@ -1,18 +1,50 @@
import * as vscode from "vscode";
+import { updateStatusBarItem } from "./updateStatusBarItem";
+let g_isEnable:boolean;
export default function changeIconColor(
isEnable: boolean,
myStatusBarItem: vscode.StatusBarItem,
- originalColor: string | vscode.ThemeColor | undefined
+ originalColor: string | vscode.ThemeColor | undefined,
+ isLangDisabled?: boolean,
+ switchTab?:boolean
): void {
myStatusBarItem.show();
- if (isEnable) {
- myStatusBarItem.backgroundColor = originalColor;
- } else {
- originalColor = myStatusBarItem.backgroundColor;
- // myStatusBarItem.backgroundColor = "#7B5F00";
- myStatusBarItem.backgroundColor = new vscode.ThemeColor(
- "statusBarItem.warningBackground"
- );
+ updateStatusBarItem(myStatusBarItem,false,false,'');
+ if(switchTab){
+ if (g_isEnable) {
+
+ myStatusBarItem.backgroundColor = originalColor;
+ if (isLangDisabled) {
+ myStatusBarItem.backgroundColor = new vscode.ThemeColor(
+ "statusBarItem.warningBackground"
+ );
+
+ }
+
+ } else {
+ originalColor = myStatusBarItem.backgroundColor;
+ // myStatusBarItem.backgroundColor = "#7B5F00";
+ myStatusBarItem.backgroundColor = new vscode.ThemeColor(
+ "statusBarItem.warningBackground"
+ );
+ }
+ }else{
+ g_isEnable = isEnable;
+ if (isEnable) {
+ myStatusBarItem.backgroundColor = originalColor;
+ if (isLangDisabled) {
+ myStatusBarItem.backgroundColor = new vscode.ThemeColor(
+ "statusBarItem.warningBackground"
+ );
+ }
+
+ } else {
+ originalColor = myStatusBarItem.backgroundColor;
+ // myStatusBarItem.backgroundColor = "#7B5F00";
+ myStatusBarItem.backgroundColor = new vscode.ThemeColor(
+ "statusBarItem.warningBackground"
+ );
+ }
}
}
diff --git a/src/utils/checkPrivacy.ts b/src/utils/checkPrivacy.ts
index 739e14a..87dd327 100644
--- a/src/utils/checkPrivacy.ts
+++ b/src/utils/checkPrivacy.ts
@@ -1,22 +1,22 @@
import { workspace, window } from "vscode";
+import { localeTag } from "../param/constparams";
//check if the user accept to share codes
export async function checkPrivacy() {
const configuration = workspace.getConfiguration("Codegeex", undefined);
let privacy = configuration.get("Privacy");
- console.log(privacy);
if (privacy === null) {
const selection = await window.showInformationMessage(
- "We highly respect the privacy of your code. Do you accept sharing the generated code only for research purposes to make CodeGeeX better? Otherwise, the code won't be stored and is only used to assist your programming.",
- "Accept",
- "Decline"
+ localeTag.privacyInfo,
+ localeTag.privacyAccept,
+ localeTag.privacyDecline
);
- if (selection !== undefined && selection === "Accept") {
+ if (selection !== undefined && selection === localeTag.privacyAccept) {
configuration
.update("Privacy", true, true)
.then((res) => console.log(res));
}
- if (selection !== undefined && selection === "Decline") {
+ if (selection !== undefined && selection === localeTag.privacyDecline) {
configuration.update("Privacy", false, true);
}
}
diff --git a/src/utils/codeGenByTemplate.ts b/src/utils/codeGenByTemplate.ts
index 0b22d5f..1432e5b 100644
--- a/src/utils/codeGenByTemplate.ts
+++ b/src/utils/codeGenByTemplate.ts
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import { getCodeCompletions } from "./getCodeCompletions";
import getDocumentLanguage from "./getDocumentLanguage";
-import { apiKey, apiSecret } from "../param/constparams";
+import { apiKey, apiSecret, localeTag } from "../param/constparams";
import { updateStatusBarItem } from "./updateStatusBarItem";
export default async function codeGenByTemplate(
@@ -51,7 +51,7 @@ export default async function codeGenByTemplate(
}
} else {
vscode.window.showInformationMessage(
- "There is an error in markup."
+ localeTag.errorInInputMarkup
);
return;
}
diff --git a/src/utils/createWebView.ts b/src/utils/createWebView.ts
index 7795317..45f3e23 100644
--- a/src/utils/createWebView.ts
+++ b/src/utils/createWebView.ts
@@ -1,14 +1,20 @@
import { ExtensionContext, ViewColumn, WebviewPanel, window } from "vscode";
-let panel: WebviewPanel | undefined;
+let panel: WebviewPanel | undefined = undefined;
//To create web view in vscode
export default async function createWebView(
context: ExtensionContext,
content?: string,
view?: string
-): Promise {
- if (!panel) {
+) {
+ const columnToShowIn = window.activeTextEditor
+ ? window.activeTextEditor.viewColumn
+ : undefined;
+
+ if (panel) {
+ panel.reveal(columnToShowIn);
+ } else {
panel = window.createWebviewPanel(
"CodeGeeX.keys",
"CodeGeeX Guide",
@@ -21,8 +27,7 @@ export default async function createWebView(
}
);
- if (panel) {
- panel.webview.html = `
+ panel.webview.html = `
@@ -36,15 +41,12 @@ export default async function createWebView(
`;
- panel.onDidDispose(
- () => {
- panel = undefined;
- },
- null,
- context.subscriptions
- );
- }
+ panel.onDidDispose(
+ () => {
+ panel = undefined;
+ },
+ null,
+ context.subscriptions
+ );
}
-
- return panel;
}
diff --git a/src/utils/getCodeTranslation.ts b/src/utils/getCodeTranslation.ts
index 94f1081..9fa7fd7 100644
--- a/src/utils/getCodeTranslation.ts
+++ b/src/utils/getCodeTranslation.ts
@@ -47,8 +47,6 @@ export function getCodeTranslation(
translation.push(translationStr);
}
- console.log("translation");
- console.log(translation);
resolve({ translation });
} else {
console.log(res);
diff --git a/src/utils/getGPTCode.ts b/src/utils/getGPTCode.ts
index 7f7237b..5eb9902 100644
--- a/src/utils/getGPTCode.ts
+++ b/src/utils/getGPTCode.ts
@@ -1,6 +1,7 @@
import { codelensProvider } from "../provider/codelensProvider";
import { updateStatusBarItem } from "./updateStatusBarItem";
import { StatusBarItem } from "vscode";
+import { localeTag } from "../param/constparams";
export const getGPTCode = (
candidateList: Array,
@@ -9,7 +10,7 @@ export const getGPTCode = (
g_isLoading: boolean
) => {
codelensProvider.clearEls();
- let content = `/* The candidate list of code generated by CodeGeeX */\n`;
+ let content = `/* ${localeTag.candidateList} */\n`;
if (candidateList.length === 0) {
updateStatusBarItem(
myStatusBarItem,
@@ -21,7 +22,6 @@ export const getGPTCode = (
}
for (let i = 0; i < candidateList.length; i++) {
const lineNum = content.split("\n").length;
- console.log(candidateList[i]);
if (i === 0) {
codelensProvider.addEl(lineNum, candidateList[i], commandid);
} else {
diff --git a/src/utils/statisticFunc.ts b/src/utils/statisticFunc.ts
index 0ed3fe2..fee7571 100644
--- a/src/utils/statisticFunc.ts
+++ b/src/utils/statisticFunc.ts
@@ -3,15 +3,12 @@ import axios from "axios";
import * as os from "os";
//import welcomePage from './welcomePage';
import { apiHerf, extensionId, extensionVersion } from "../param/constparams";
-import { enableStats } from "../localconfig";
-
const privacy = vscode.workspace.getConfiguration("Codegeex").get("Privacy");
export function getOpenExtensionData(): Promise {
- return new Promise((resolve,reject) => {
- if(enableStats){
- try {
+ return new Promise((resolve, reject) => {
+ try {
axios
.post(`${apiHerf}/tracking/insertVscodeStartRecord`, {
vscodeMachineId: vscode.env.machineId,
@@ -37,10 +34,6 @@ export function getOpenExtensionData(): Promise {
} catch (e) {
reject("error");
}
- }else{
- resolve("No stats");
- }
-
});
}
export function getStartData(
@@ -49,31 +42,32 @@ export function getStartData(
lang: string,
mode?: string
): Promise {
- return new Promise((resolve,reject) => {
- if(enableStats){
+ return new Promise((resolve, reject) => {
+ const startParam = {
+ vscodeMachineId: vscode.env.machineId,
+ vscodeSessionId: vscode.env.sessionId,
+ requestPhase: "start",
+ inputContent: privacy ? inputText : null,
+ prompt: privacy ? prompt : null,
+ lang: lang,
+ mode: mode ? mode : null,
+ extensionId: extensionId,
+ extensionVersion: extensionVersion
- const startParam = {
- vscodeMachineId: vscode.env.machineId,
- vscodeSessionId: vscode.env.sessionId,
- requestPhase: "start",
- inputContent: privacy ? inputText : null,
- prompt: privacy ? prompt : null,
- lang: lang,
- mode: mode ? mode : null,
- };
- try {
- axios
- .post(`${apiHerf}/tracking/vsCodeOperationRecord`, startParam)
- .then((res) => {
- console.log("开始请求测试", res);
- let commandid = res.data.data.id || "";
- resolve(commandid);
- });
- } catch (err) {
- reject("");
- }
- }else{
- reject('');
+ };
+ try {
+ axios
+ .post(`${apiHerf}/tracking/vsCodeOperationRecord`, startParam)
+ .then((res) => {
+ console.log("开始请求测试", res);
+ let commandid = res.data.data.id || "";
+ resolve(commandid);
+ })
+ .catch((err) => {
+ reject("error");
+ });
+ } catch (err) {
+ reject("");
}
});
}
@@ -84,36 +78,55 @@ export function getEndData(
acceptItem?: string | null,
completions?: Array | string
): Promise {
- return new Promise((resolve,reject) => {
- if(enableStats){
- if (commandid === "") {
- reject("No command id");
- }
-
- let endparam = {
- id: commandid,
- requestPhase: "end",
- outputContent: privacy ? acceptItem : null,
- modelStatus: -1,
- message: message, //err.message,
- num: privacy ? completions?.length : 0,
- numContent: privacy ? completions?.toString() : null,
- whetherAdopt: isAdopted,
- };
- try{
-
- axios
- .post(`${apiHerf}/tracking/vsCodeOperationRecord`, endparam)
- .then((res) => {
- console.log("测试结束埋点", res);
- resolve("");
- })
- }catch(err){
- reject("");
- }
- }else{
- resolve("");
+ return new Promise((resolve, reject) => {
+ if (commandid === "") {
+ reject("No command id");
+ }
+ let endparam = {
+ id: commandid,
+ requestPhase: "end",
+ outputContent: privacy ? acceptItem : null,
+ modelStatus: -1,
+ message: message, //err.message,
+ num: privacy ? completions?.length : 0,
+ numContent: privacy ? completions?.toString() : null,
+ whetherAdopt: isAdopted,
+ extensionId: extensionId,
+ extensionVersion: extensionVersion
+ };
+ try {
+ axios
+ .post(`${apiHerf}/tracking/vsCodeOperationRecord`, endparam)
+ .then((res) => {
+ console.log("测试结束埋点", res);
+ resolve("");
+ })
+ .catch((e) => {
+ console.log("结束埋点错误", e);
+ reject("error");
+ });
+ } catch (e) {
+ reject("error");
}
-
});
}
+export function getTotalRequestNum(): Promise {
+ return new Promise((resolve, reject) => {
+ try {
+ axios
+ .get(`${apiHerf}/tracking/selectByVscodeMachineIdTotal?vscodeMachineId=${vscode.env.machineId}`)
+ .then((res) => {
+ console.log("获取总请求数", res);
+ if(res.data.code === 200 && res.data.data) {
+ resolve(res.data.data);
+ } else {
+ reject("error");
+ }
+ })
+ } catch (e) {
+ console.log(e);
+ reject("error");
+ }
+
+ });
+}
\ No newline at end of file
diff --git a/src/utils/survey.ts b/src/utils/survey.ts
new file mode 100644
index 0000000..4d8768b
--- /dev/null
+++ b/src/utils/survey.ts
@@ -0,0 +1,30 @@
+import { getTotalRequestNum } from "./statisticFunc";
+import * as vscode from "vscode";
+import { localeTag, surveyUrl } from "../param/constparams";
+import { acceptedsurvey } from "../param/configures";
+
+let totolRequestNum: number;
+export default async function survey() {
+ try {
+ totolRequestNum = await getTotalRequestNum();
+ } catch (err) {
+ console.error(err);
+ totolRequestNum = 0;
+ }
+ let configuration = vscode.workspace.getConfiguration('Codegeex',undefined)
+ if (totolRequestNum >= 2000 && acceptedsurvey=== null) {
+ const selection = await vscode.window.showInformationMessage(
+ localeTag.surveyInfo,
+ localeTag.surveyYes,
+ localeTag.surveyNo
+ );
+ if (selection === localeTag.surveyYes) {
+ configuration.update('Survey',true,true)
+ let uri = vscode.Uri.parse(surveyUrl);
+ vscode.env.openExternal(uri);
+ }
+ if(selection === localeTag.surveyNo){
+ configuration.update('Survey',false,true)
+ }
+ }
+}
diff --git a/src/welcomePage.ts b/src/welcomePage.ts
index 9628b55..fb73c51 100644
--- a/src/welcomePage.ts
+++ b/src/welcomePage.ts
@@ -1,9 +1,9 @@
import { EventEmitter } from "stream";
-import { ExtensionContext, WebviewPanel } from "vscode";
+import { ExtensionContext, WebviewPanel,window } from "vscode";
import createWebView from "./utils/createWebView";
import { controls } from "./param/configures";
-let panel: WebviewPanel;
+let panel: WebviewPanel | undefined = undefined;
export default async function welcomePage(
context: ExtensionContext
): Promise {
@@ -92,11 +92,9 @@ export default async function welcomePage(
}
switchTo(1);
- `;
- if (!panel) {
- panel = await createWebView(context, content);
- }
- panel.reveal();
+ `;
+ await createWebView(context, content);
+
}
const keys = `