Prerequisite
- 一个提供hk以外节点代理的vpn
- 注册一个chatgpt账号
- vscode客户端(是不是很严谨?)
1.和2.可以参考国内自助获取chatgpt方法
3.指路官网自行根据计算机型号下载
下载与配置
打开vscode侧边栏的<拓展>,搜索chatgpt
这里有很多自称为chatgpt的插件,我们下载图标是紫色的这个:
下载后全局启用,重启vscode会在侧边栏发现这个选项:
点击,会产生一个界面等你log in
这时打开网址
选择create new key->copy
最好把这个key保存下来,否则之后每次要重新生成
再次打开vscode,点击log in,粘贴这个key即可开始与chatgpt对话
这里提供两种方式:
- 直接在对话框进行指示
- 选中一段代码,点击鼠标右键,可以看到有关chatgpt的指令
这里提供一些常用指令:
Basic commands
ChatGPT: Ad-hoc prompt
Ad-hoc custom prompt prefix for the selected code. Right click on a selected block of code, run command. You will be asked to fill in your preferred custom prefix and the extension will remember that string for your subsequent ad-hoc queries.
ChatGPT: Add tests
Write tests for you. Right click on a selected block of code, run command. “default”: “Implement tests for the following code”, “description”: “The prompt prefix used for adding tests for the selected code”
ChatGPT: Find bugs
Analyze and find bugs in your code. Right click on a selected block of code, run command. “default”: “Find problems with the following code”, “description”: “The prompt prefix used for finding problems for the selected code”
ChatGPT: Optimize
Add suggestions to your code to improve. Right click on a selected block of code, run command. “default”: “Optimize the following code”, “description”: “The prompt prefix used for optimizing the selected code”
ChatGPT: Explain
Explain the selected code. Right click on a selected block of code, run command. “default”: “Explain the following code”, “description”: “The prompt prefix used for explaining the selected code”
ChatGPT: Add comments
Add comments for the selected code. Right click on a selected block of code, run command. “default”: “Add comments for the following code”, “description”: “The prompt prefix used for adding comments for the selected code”
ChatGPT: Custom prompt 1
Your custom prompt 1. It’s disabled by default, please set to a custom prompt and enable it if you prefer using customized prompt “default”: “”,
ChatGPT: Custom prompt 2
Your custom prompt 2. It’s disabled by default, please set to a custom prompt and enable it if you prefer using customized prompt “default”: “”,
Other available commands
ChatGPT: Ask anything
Free-form text questions within conversation window.
ChatGPT: Reset session
Clears the current session and resets your connection with ChatGPT
ChatGPT: Clear conversation
Clears the conversation window and resets the thread to start a new conversation with ChatGPT.
ChatGPT: Export conversation
Exports the whole conversation in Markdown for you to easily store and find the Q&A list.
注意:非代码问题
想问其他非代码问题,需要先在对话框键入
ChatGPT: Ask anything
即可开始提问