一、JetBrains IDEA 中安装教学
第一步:事先准备
- 支持系统:Windows 7 ~ Windows 11、Linux、macOS;
- 下载并安装兼容的 JetBrains IDEA 2021.2 及以上版本,推荐使用2024.1及以上的版本以获取最佳兼容性;
- 安装 Python 3.7 或更高版本
第二步:在 IntelliJ IDEA 中安装CodeGPT
打开 IntelliJ IDEA 设置窗口, File —> Settings —> Plugins—> Marketplace 在输入框搜索 CodeGPT,找到CodeGPT后单击 Install 进行安装。
安装完成后,重启 IntelliJ IDEA。
重启完成后在右侧可以看到CodeGPT 图标,至此CodeGPT安装完成。
CodeGPT初体验,直接和CodeGPT对话,可使其生成代码,在对话框输入:“用java 写一个过滤数字的方法并返回测试”, 此时使用的默认大模型,第三步会说明怎么配置DeepSeek大模型
完成的代码如下:
public class DigitFilter {// Method to filter digits from a stringpublic static String filterDigits(String input) {StringBuilder digits = new StringBuilder();for (char c : input.toCharArray()) {if (Character.isDigit(c)) {digits.append(c);}}return digits.toString();}// Unit testpublic static void main(String[] args) {String testInput = "abc123xyz456";String expectedOutput = "123456";String result = filterDigits(testInput);if (result.equals(expectedOutput)) {System.out.println("Test Passed!");} else {System.out.println("Test Failed. Expected: " + expectedOutput + ", Got: " + result);}}
}
代码执行结果 Test Passed!:
DeepSeek_56">第三步:在CodeGPT中配置DeepSeek
方法1(收费)
3.1.1 登录deepseek API 开发平台创建一个 API Key,开发平台地址:https://www.deepseek.com/
3.1.2 打开 IntelliJ IDEA 设置窗口, File —> Settings —> Tools —> CodeGPT —> Providers —> Custom OpenAI
- preset template 选 OpenAI
- API Key 填写上面创建的 API key
Chat Completions 设置:
- URL 修改为:https://api.deepseek.com/chat/completions
- Body 请求体 model 参数修改为:deepseek-chat
Code Completions 设置:
- 勾选☑️ Enable code completions及勾选☑️ Parse response as Chat Completions
- 选择FIM template 选择为 DeepSeek Coder 。
- 在URL处粘贴URL:https://api.deepseek.com/chat/completions
- 将Body 请求体 model 参数修改为:deepseek-reasoner
通过上述步骤,即可配置完成,配置完成后,点击Apply和OK即可。
如果还不明白如何配置,可以参考下官方提供的配置策略:DeepSeekf配置手册配置手册
3.1.3 DeepSeek用量统计,登录deepseek API 开发平台 —> 用量信息,可以查看消费金额:
方法2 (免费)
3.2.1 创建CodeGPT API Key ,登录地址:https://www.codegpt.ee/signin,登录后单击 Providers —> Cloud —> CodeGPT —> Sign up Here —> 找到 Your API Keys 单击copy图标
3.2.2 打开 IntelliJ IDEA 设置窗口, File —> Settings —> Tools —> CodeGPT —> Providers —> CodeGPT
- 填写 API key,把上面API key 粘贴进去
- Chat model 选择 DeepSeek V3
- Code model 默认Codestral 不用改
- 勾选☑️ Enable code Assisant及勾选☑️ Enable code Completions
DeepSeek V3 设置" />
至此DeepSeek设置完成,下一篇展示如何高效使用 DeepSeek。
二、IDE集成DeepSeek保姆级教学(使用篇)
– 欢迎点赞、关注、转发、收藏【技术咖啡馆C】,各大平台同名。