-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b06aaa
commit 523fa15
Showing
51 changed files
with
3,078 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
out | ||
dist | ||
node_modules | ||
.vscode-test/ | ||
*.vsix | ||
*.js.map | ||
src/localconfig.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Change Log | ||
|
||
v1.0.7 (2022-11-28) | ||
|
||
- Add status bar command and user setting to disable specific languages | ||
|
||
- Add preference for user to decide generation code line by line or automatic | ||
|
||
- Add welcome page, new user will see the welcome page first when activate the extension or you can commmand it in command palette by codegeex.welcome-page | ||
|
||
- Fix some known issues | ||
|
||
v1.0.6 (2022-11-11) | ||
|
||
- Add new mode Translation mode for user to translate code | ||
|
||
- Add three parameters for user to change in order to get better code suggestions | ||
|
||
- Add commands of three other modes to the right click menu | ||
|
||
- Fix some known issues | ||
|
||
v1.0.5 (2022-11-04) | ||
|
||
- Add new command to get new suggestion | ||
|
||
- Add more information to the status bar | ||
|
||
v1.0.4 (2022-10-28) | ||
|
||
- Fixed some known issues | ||
|
||
v1.0.3 (2022-10-20) | ||
|
||
- Fixed some known issues | ||
|
||
v1.0.2 (2022-09-22) | ||
|
||
- Fixed some known issues | ||
|
||
v1.0.1 (2022-09-21) | ||
|
||
- Fixed some known issues | ||
|
||
v1.0.0 (2022-09-20) | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
![codegeex_logo](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/codegeex_logo.png) | ||
|
||
🌐 <a href="https://github.com/THUDM/CodeGeeX/blob/main/vscode-extension/README_zh.md" target="_blank">中文</a> | ||
|
||
![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, 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 [[email protected]](mailto:[email protected]). | ||
|
||
## Basic Usage | ||
Make sure vscode version is >= 1.68.0. Install the extension and enable it globally. There are three modes of usage: | ||
|
||
- **Stealth mode**: Keep CodeGeeX activated, it will start generating codes when you stop writing (the icon at the bottom of VSCode starts spinning). When the generated code is shown in gray, just press ``Tab`` to insert the generated codes. | ||
- **Interactive mode**: Press ``Ctrl+Enter`` to activate the interactive mode, CodeGeeX will generate ``X`` candidates and show them in the right panel (``X`` can be modified in extension settings ``Candidate Num``). Then, select the best candidate by clicking on it. | ||
- **Translation mode**: Select code, and press ``Ctrl+Alt+T`` to activate the translation mode. Then, choose the language of the selected code. You will get the code translated into the same language as your current editor. Click on the ``use code`` button to insert the result. You can also configure in the settings whether to comment out the original code or to replace it. | ||
- **Prompt mode**: Select codes to be used as input, then press ``Alt/Option+t`` to trigger the prompt mode. It will show a list of pre-defined prompt templates and choose one to generate codes with your input. This mode is fully customizable, you can add your own templates in the extension settings ``Prompt Templates``. | ||
|
||
## Privacy | ||
|
||
We highly respect the privacy of your code. The code is only used as the input of CodeGeeX to assist your programming. At the first time of usage, we will ask if you agree to share the generated code only for research purpose (**disabled** by default). | ||
|
||
## Guidance | ||
Please see the details and examples for how to use the three modes in CodeGeeX: | ||
### Stealth mode | ||
In this mode, CodeGeeX will start generating codes when you stop writing (the icon at the bottom of VSCode starts spinning). When the generated code is shown in gray, just press ``Tab`` to insert the generated codes. You can also press ``Alt/Option+[`` or ``]`` to change between candidates. If you are not satisfied with the current suggestions, you can also press ``Alt/Option+N`` to get new suggestions. Change the number of candidates in the extension settings ``Candidate Num`` (more candidates will slow down the generation speed). **Note**: The generation always starts at the current position of your cursor, thus if you modify the code before the generation is finished, it will probably cause bugs. We keep working on making the generation faster. | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/bubble_sort_go.gif) | ||
|
||
### Interactive mode | ||
In this mode, press ``Ctrl+Enter`` to generate codes and visualize the candidates in another panel. Then, click on the best candidate to insert the generated codes to the current position of cursor. | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/interactive_mode2.gif) | ||
|
||
### Translation mode | ||
In this mode, paste or tape some code from another language to the current file, select the code, and press ``Ctrl+Alt+T``. Then, choose the language of the selected code. Wait for a few seconds, you will get the code translated into the same language as your current editor. Click on the ``use code`` button to insert the result into the current position of your cursor. You can also configure in the settings whether to comment out the original code or to replace it. | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/translation_cpp_to_python.gif) | ||
|
||
### Prompt mode | ||
In this mode, you can add extra prompts to the input and implement some cool features, like code explanation, summarization, generation with specific coding style, and more. The principle behind is the few-shot ability of CodeGeeX. When you provide a few examples as extra prompts in the input, CodeGeeX will imitate what are done by these examples and generate codes accordingly. For example, you can give an example that explains each line of code. Select the code you want to explain, then press ``Alt/Option+t`` to trigger the prompt mode. It will show a list of pre-defined prompt templates and choose the ``explanation`` to generate codes with your input. Magically, the codes will be explained line by line. | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/explanation_python.gif) | ||
|
||
The template of the above example looks like the following, which contains ``[Example code]``, ``<INPUT>``, ``[Example code with explanation]`` and ``[Explanation head]``. ``<INPUT>`` is where the selected code will be inserted. ``<INPUT0:1>`` means the first line of your input (which is used here to ensure the same function will be explained). When you use the prompt mode, CodeGeeX will combine your input with the template and use them all as the input to generate codes. | ||
|
||
```python | ||
# language: Python | ||
|
||
def sum_squares(lst): | ||
sum = 0 | ||
for i in range(len(lst)): | ||
if i % 3 == 0: | ||
lst[i] = lst[i]**2 | ||
elif i % 4 == 0: | ||
lst[i] = lst[i]**3 | ||
sum += lst[i] | ||
return sum | ||
|
||
<INPUT> | ||
|
||
# Explain the code line by line | ||
def sum_squares(lst): | ||
# initialize sum | ||
sum = 0 | ||
# loop through the list | ||
for i in range(len(lst)): | ||
# if the index is a multiple of 3 | ||
if i % 3 == 0: | ||
# square the entry | ||
lst[i] = lst[i]**2 | ||
# if the index is a multiple of 4 | ||
elif i % 4 == 0: | ||
# cube the entry | ||
lst[i] = lst[i]**3 | ||
# add the entry to the sum | ||
sum += lst[i] | ||
# return the sum | ||
return sum | ||
|
||
# Explain the code line by line | ||
<INPUT:0,1> | ||
``` | ||
|
||
And here is another example for python docstring generation | ||
```python | ||
def add_binary(a, b): | ||
''' | ||
Returns the sum of two decimal numbers in binary digits. | ||
Parameters: | ||
a (int): A decimal integer | ||
b (int): Another decimal integer | ||
Returns: | ||
binary_sum (str): Binary string of the sum of a and b | ||
''' | ||
binary_sum = bin(a+b)[2:] | ||
return binary_sum | ||
|
||
<INPUT> | ||
``` | ||
|
||
The templates are fully customizable, you can add your own templates in the extension settings ``Prompt Templates``. ``key`` is the name that you want to show in the list of templates, ``value`` is the path to the template file (``.txt``, ``.py``, ``.h``, etc). Try this feature and write your own templates, you can make the generated codes follow your coding style, generate with a specific function name, or add a specific comment, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
![codegeex_logo](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/codegeex_logo.png) | ||
|
||
CodeGeeX是一个具有130亿参数的多编程语言代码生成预训练模型,使用超过二十种编程语言训练得到。基于CodeGeeX开发的插件可以实现通过描述生成代码、补全代码、代码翻译等一系列功能。CodeGeeX同样提供可以定制的**提示模式(Prompt Mode)**,构建专属的编程助手。Happy Coding! | ||
|
||
VS Code插件市场搜索"codegeex"即可免费使用,更多关于CodeGeeX信息请见我们的[主页](https://models.aminer.cn/codegeex/) and [GitHub仓库](https://github.com/THUDM/CodeGeeX)。 | ||
|
||
如使用过程中遇到问题或有任何改进意见,欢迎发送邮件到[[email protected]](mailto:[email protected])反馈! | ||
|
||
## 基本用法 | ||
安装插件并全局激活CodeGeeX,有以下三种使用模式: | ||
|
||
- **隐匿模式**: 保持CodeGeeX处于激活状态,当您停止输入时,会从当前光标处开始生成(右下角CodeGeeX图标转圈表示正在生成)。 生成完毕之后会以灰色显示,按``Tab``即可插入生成结果。 | ||
- **交互模式**: 按``Ctrl+Enter``激活交互模式,CodeGeeX将生成``X``个候选,并显示在右侧窗口中(``X`` 数量可以在设置的``Candidate Num``中修改)。 点击候选代码上方的``use code``即可插入。 | ||
- **翻译模式**: 选择代码,然后按下``Ctrl+Alt+T``激活翻译模式,CodeGeeX会把该代码翻译成匹配您当前编辑器语言的代码。点击翻译结果上方的``use code``插入。您还可以在设置中选择您希望插入的时候如何处理被翻译的代码,您可以选择注释它们或者覆盖它们。 | ||
- **提示模式**: 选择需要作为输入的代码,按``Alt/Option+t``触发提示模式,会显示预定义模板列表,选择其中一个模板,即可将代码插入到模板中进行生成。 这个模式高度自定义,可以在设置中 ``Prompt Templates``修改或添加模板内容,为模型加入额外的提示。 | ||
|
||
## 隐私声明 | ||
|
||
我们高度尊重用户代码的隐私,代码仅用来辅助编程。在您第一次使用时,我们会询问您是否同意将生成的代码用于研究用途,帮助CodeGeeX变得更好(该选项默认**关闭**)。 | ||
|
||
## 使用指南 | ||
|
||
以下是CodeGeeX几种模式的详细用法: | ||
|
||
###隐匿模式 | ||
|
||
在该模式中,CodeGeeX将在您停止输入时,从光标处开始生成(右下角CodeGeeX图标转圈表示正在生成)。生成完毕之后会以灰色显示,按``Tab``即可插入生成结果。 在生成多个候选的情况下,可以使用``Alt/Option+[`` 或 ``]``在几个候选间进行切换。如果你对现有建议不满意,可以使用``Alt/Option+N``去获得新的候选。可以在设置中改变``Candidate Num``(增加个数会导致生成速度相对变慢)。**注意**:生成总是从当前光标位置开始,如果您在生成结束前移动光标位置,可能会导致一些bugs。我们正在努力使生成速度变得更快以提升用户体验。 | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/bubble_sort_go.gif) | ||
|
||
### 交互模式 | ||
|
||
在该模式中,按``Ctrl+Enter``激活交互模式,CodeGeeX将生成``X``个候选,并显示在右侧窗口中(``X`` 数量可以在设置的``Candidate Num``中修改)。 点击候选代码上方的``use code``即可插入结果到为当前光标位置。 | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/interactive_mode2.gif) | ||
|
||
### 翻译模式 | ||
|
||
在当前的语言的文本编辑器中输入或者粘贴其他语言的代码,您用鼠标选择这些代码,然后按下``Ctrl+Alt+T``激活翻译模式,您根据提示选择该代码的语言,然后CodeGeeX会帮您把该代码翻译成匹配您当前编辑器语言的代码。点击翻译结果上方的``use code``即可插入。您还可以在设置中选择您希望插入的时候如何处理被翻译的代码,您可以选择注释它们或者覆盖它们。 | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/translation_cpp_to_python.gif) | ||
|
||
### 提示模式 | ||
|
||
在该模式中,您可以在输入中添加额外的提示来实现一些有趣的功能,包括并不限于代码解释、概括、以特定风格生成等。该模式的原理是利用了CodeGeeX强大的少样本生成能力。当您在输入中提供一些例子时,CodeGeeX会模仿这些例子并实现相应的功能。比如,您可以自定义模板中提供一段逐行解释代码的例子。选择您想要解释的代码,按``Alt/Option+t``触发提示模式,选择您写好的模板(如``explanation``),CodeGeeX就会解释您输入的代码。以下我们会详细介绍如何制作模板。 | ||
|
||
![image](https://lfs.aminer.cn/misc/wangshan/pretrain/codegeex/explanation_python.gif) | ||
|
||
上述例子中的模板如下图所示,由``[示例代码]``, ``<INPUT>``, ``[带解释的示例代码]`` and ``[输出函数头]`` 。``<INPUT>``表示您选中的代码将会插入的位置。 ``<INPUT0:1>`` 这一句用来保证模型解释的是同一个函数。当使用提示模式时,CodeGeeX会将您选择的代码(插入到<INPUT>部分)和模板代码相结合,一起作为模型的输入。 | ||
|
||
```python | ||
# language: Python | ||
|
||
def sum_squares(lst): | ||
sum = 0 | ||
for i in range(len(lst)): | ||
if i % 3 == 0: | ||
lst[i] = lst[i]**2 | ||
elif i % 4 == 0: | ||
lst[i] = lst[i]**3 | ||
sum += lst[i] | ||
return sum | ||
|
||
<INPUT> | ||
|
||
# Explain the code line by line | ||
def sum_squares(lst): | ||
# initialize sum | ||
sum = 0 | ||
# loop through the list | ||
for i in range(len(lst)): | ||
# if the index is a multiple of 3 | ||
if i % 3 == 0: | ||
# square the entry | ||
lst[i] = lst[i]**2 | ||
# if the index is a multiple of 4 | ||
elif i % 4 == 0: | ||
# cube the entry | ||
lst[i] = lst[i]**3 | ||
# add the entry to the sum | ||
sum += lst[i] | ||
# return the sum | ||
return sum | ||
|
||
# Explain the code line by line | ||
<INPUT:0,1> | ||
``` | ||
|
||
以下是另一个Python文档字符串生成的例子,CodeGeeX在您写新函数时会模仿该注释的格式: | ||
```python | ||
def add_binary(a, b): | ||
''' | ||
Returns the sum of two decimal numbers in binary digits. | ||
Parameters: | ||
a (int): A decimal integer | ||
b (int): Another decimal integer | ||
Returns: | ||
binary_sum (str): Binary string of the sum of a and b | ||
''' | ||
binary_sum = bin(a+b)[2:] | ||
return binary_sum | ||
|
||
<INPUT> | ||
``` | ||
|
||
模板文件是高度自定义化的,您可以将自定义模板添加到插件设置中的``Prompt Templates``中。 ``key``表示模板的名字, ``value``是模板文件的路径(可以是您电脑上的任一路径,``.txt``, ``.py``, ``.h``, 等格式文件均可)。通过该功能,您可以让CodeGeeX生成具有特定风格或功能的代码,快尝试定义自己的专属模板吧! |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.