IntelliJ IDEA 中集成 Continue、DeepSeek 与硅基流动平台:开启 AI 编程新体验

IntelliJ IDEA 中集成 Continue、DeepSeek 与硅基流动平台:开启 AI 编程新体验

前言

近年来,人工智能技术的快速发展正在重塑编程领域。AI 工具通过智能代码补全、自动错误检测、自然语言转代码等功能,大幅提升了开发效率。开发者无需再手动处理重复性代码,也减少了因低级错误导致的调试时间。例如,DeepSeek 等大模型在代码生成任务中表现优异,硅基流动平台则为开发者提供了便捷的模型调用服务,而 Continue 插件则将二者能力无缝集成到 IDE 中,形成完整的 AI 编程解决方案。


工具解释

1. Continue 插件

Continue 是一款开源的 AI 编程助手插件,支持 VS Code、IntelliJ IDEA 等主流 IDE。它通过调用外部 AI 模型(如 ChatGPT,DeepSeek)提供代码补全、重构建议、单元测试生成等功能。其优势在于高度可定制化,开发者可灵活配置模型和功能。

2. DeepSeek 模型

由深度求索公司推出的 DeepSeek 系列模型(如 DeepSeek-R1/V3)在代码生成、数学推理等任务中性能卓越,多项指标对齐国际顶尖模型。其开源特性(MIT 协议)和高效的推理速度,使其成为开发者首选的 AI 助手。

3. 硅基流动平台

硅基流动(SiliconFlow)是一个提供多模型 API 服务的云平台,支持 DeepSeek、QWEN 等模型的快速调用。其特色包括:

  • 免费额度:新用户注册即送 2000 万 Token(约 14 元);
  • 高性能推理:通过自研推理引擎优化模型响应速度;
  • 多框架兼容:支持 OpenAI 标准接口,便于 IDE 插件集成。

安装与配置

步骤 1:安装 Continue 插件

  1. 打开 IntelliJ IDEA,进入 File > Settings > Plugins
  2. 搜索 Continue 并安装,重启 IDE 完成激活。
    在这里插入图片描述

步骤 2:注册硅基流动平台

  1. 访问 硅基流动官网 完成注册;
  2. 个人中心 > API 密钥 中创建 API Key。
    在这里插入图片描述

步骤 3:配置 Continue 插件

  1. 在 IDEA 中打开 Continue 的配置文件 config.json
    在这里插入图片描述

  2. 添加硅基流动的 API 信息及模型参数(将已下配置全局覆盖后,将apiKey全局替换为您的API密钥即可):

{
  "models": [
    {
      "title": "deepseek-ai/DeepSeek-R1",
      "model": "deepseek-ai/DeepSeek-R1",
      "contextLength": 30000,
      "provider": "openai",
      "apiBase": "https://api.siliconflow.cn/v1",
      "apiKey": "xxxxxxx",
      "requestOptions": {
        "extraBodyProperties": {
          "transforms": []
        }
      }
    },
    {
      "title": "deepseek-ai/DeepSeek-V3",
      "model": "deepseek-ai/DeepSeek-V3",
      "contextLength": 30000,
      "provider": "openai",
      "apiBase": "https://api.siliconflow.cn/v1",
      "apiKey": "xxxxxxx",
      "requestOptions": {
        "extraBodyProperties": {
          "transforms": []
        }
      }
    },
    {
      "title": "deepseek-ai/DeepSeek-V2.5",
      "model": "deepseek-ai/DeepSeek-V2.5",
      "contextLength": 30000,
      "provider": "openai",
      "apiBase": "https://api.siliconflow.cn/v1",
      "apiKey": "xxxxxxx",
      "requestOptions": {
        "extraBodyProperties": {
          "transforms": []
        }
      }
    },
    {
      "title": "Qwen/Qwen2.5-72B-Instruct-128K",
      "model": "Qwen/Qwen2.5-72B-Instruct-128K",
      "contextLength": 30000,
      "provider": "openai",
      "apiBase": "https://api.siliconflow.cn/v1",
      "apiKey": "xxxxxxx",
      "requestOptions": {
        "extraBodyProperties": {
          "transforms": []
        }
      }
    }
  ],
  "customCommands": [
    {
      "name": "test",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    },
    {
      "name": "explain",
      "prompt": "{{{ input }}}\n\n详细解释所选代码。详细说明其功能、用途和工作原理。使用示例来说明您的解释。",
      "description": "解释代码"
    },
    {
      "name": "fix",
      "prompt": "{{{ input }}}\n\n分析并修复代码中的错误。提供详细的解释和解决方案,包括但不限于语法错误、逻辑错误或性能问题。确保您的解决方案是正确的,并且能够解决所有已知的问题。",
      "description": "修复代码"
    },
    {
      "name": "check",
      "prompt": "{{{ input }}}\n\n请阅读突出显示的代码并检查是否有任何错误。您应该查找以下内容并保持高度警惕:\n- 语法错误\n- 逻辑错误\n- 安全漏洞\n- 性能问题\n- 任何其他看似错误的内容\n\n一旦您发现错误,请尽可能清楚地解释,但不要使用多余的词语。例如,不要说“我认为第 5 行有一个语法错误”,而应该说“第 5 行有语法错误”。针对发现的每个错误,给出一个要点作为答案。",
      "description": "检查代码是否存在错误"
    }
  ],
  "tabAutocompleteModel": [
    {
      "title": "deepseek-ai/DeepSeek-V3",
      "provider": "openai",
      "model": "deepseek-ai/DeepSeek-V3",
      "contextLength": 30000,
      "apiBase": "https://api.siliconflow.cn/v1",
      "apiKey": "xxxxxxx",
      "useLegacyCompletionsEndpoint": false
    },
    {
      "title": "deepseek-ai/DeepSeek-V2.5",
      "provider": "openai",
      "model": "deepseek-ai/DeepSeek-V2.5",
      "contextLength": 30000,
      "apiBase": "https://api.siliconflow.cn/v1",
      "apiKey": "xxxxxxx",
      "useLegacyCompletionsEndpoint": false
    }
  ],
  "contextProviders": [
    {
      "name": "code",
      "params": {
        "nRetrieve": 25,
        "nFinal": 5,
        "useReranking": true
      },
      "useLegacyCompletionsEndpoint": false
    },
    {
      "name": "docs",
      "params": {}
    },
    {
      "name": "diff",
      "params": {
        "nRetrieve": 25,
        "nFinal": 5,
        "useReranking": true
      },
      "useLegacyCompletionsEndpoint": false
    },
    {
      "name": "terminal",
      "params": {}
    },
    {
      "name": "problems",
      "params": {}
    },
    {
      "name": "folder",
      "params": {}
    },
    {
      "name": "codebase",
      "params": {
        "nRetrieve": 25,
        "nFinal": 5,
        "useReranking": true
      },
      "useLegacyCompletionsEndpoint": false
    }
  ],
  "slashCommands": [
    {
      "name": "edit",
      "description": "Edit selected code"
    },
    {
      "name": "comment",
      "description": "Write comments for the selected code"
    },
    {
      "name": "share",
      "description": "Export the current chat session to markdown"
    },
    {
      "name": "cmd",
      "description": "Generate a shell command"
    },
    {
      "name": "commit",
      "description": "Generate a git commit message"
    }
  ],
  "embeddingsProvider": {
    "provider": "openai",
    "model": "BAAI/bge-m3",
    "apiBase": "https://api.siliconflow.cn/v1",
    "apiKey": "xxxxxxx"
  },
  "rerank": {
    "title": "BAAI/bge-reranker-v2-m3",
    "model": "BAAI/bge-reranker-v2-m3",
    "provider": "openai",
    "apiBase": "https://api.siliconflow.cn/v1",
    "apiKey": "xxxxxxx"
  },
  "tabAutocompleteOptions": {
    "template": "Please teach me what I should write in the `hole` tag, but without any further explanation and code backticks, i.e., as if you are directly outputting to a code editor. It can be codes or comments or strings. Don't provide existing & repetitive codes. If the provided prefix and suffix contain incomplete code and statement, your response should be able to be directly concatenated to the provided prefix and suffix. Also note that I may tell you what I'd like to write inside comments. \n{{{prefix}}}<hole></hole>{{{suffix}}}\n\nPlease be aware of the environment the hole is placed, e.g., inside strings or comments or code blocks, and please don't wrap your response in ```. You should always provide non-empty output.\n",
    "maxPromptTokens": 2048,
    "prefixPercentage": 0.85,
    "maxSuffixPercentage": 0.15,
    "debounceDelay": 500,
    "slidingWindowPrefixPercentage": 0.75,
    "slidingWindowSize": 350,
    "maxSnippetPercentage": 0.6,
    "recentlyEditedSimilarityThreshold": 0.3,
    "onlyMyCode": false,
    "useOtherFiles": false,
    "useRecentlyEdited": true,
    "recentLinePrefixMatchMinLength": 7
  }
}
  1. 保存配置后,即可在 IDE 中调用模型
    在这里插入图片描述

使用方法

功能 1:智能代码补全

  • 场景:编写代码时,输入部分关键字后,Continue 会根据上下文自动生成补全建议。
  • 开关索引
    在这里插入图片描述

功能 2:代码优化与错误检测

  • 操作:选中代码片段,右键选择 Fix 或 Check 命令,插件将分析代码中的逻辑错误、性能问题并给出优化建议。

功能 3:生成单元测试

  • 操作:选中函数代码,执行 Test 命令,插件会自动生成覆盖多种边界条件的测试用例。

功能 4:自然语言问答

  • 操作:在 Continue 的聊天界面输入问题(如“如何实现快速排序?”),模型将返回代码示例及详细解释1112。

总结

通过将 Continue 插件、DeepSeek 模型与硅基流动平台集成到 IntelliJ IDEA 中,开发者可以:

  1. 降低成本:利用免费 Token 和开源模型,避免高昂的订阅费用;
  2. 提升效率:自动化处理重复性编码任务,专注核心逻辑设计;
  3. 灵活扩展:支持多种模型切换,适应不同开发场景。

未来,随着 AI 模型的进一步优化和开发工具的深度整合,“人机协同编程”将成为主流。开发者需持续探索 AI 工具的可能性,将其转化为生产力跃升的加速器。

提示:若遇到 API 限流问题,可调整插件的上下文窗口大小或请求间隔。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值