跳到主要内容
选择一个与聊天指令不同的模型来响应编辑指令通常很有用,因为编辑通常更具代码特异性,并且可能需要较少的会话可读性。 在 Continue 中,您可以将 edit 添加到模型的角色中,以指定它可以用于编辑请求。如果未指定编辑模型,则使用选定的 chat 模型。
config.yaml
name: My Config
version: 0.0.1
schema: v1

models:
  - name: Claude 4 Sonnet
    provider: anthropic
    model: claude-3-5-sonnet-latest
    apiKey: <YOUR_ANTHROPIC_API_KEY>
    roles:
      - edit
中心探索编辑模型。通常,我们对编辑的建议与对聊天的建议重叠。

模型推荐

模型作用最佳开源模型最佳闭源模型备注
聊天 编辑封闭模型和开放模型性能非常相似

提示模板

您可以通过在模型配置中设置 promptTemplates.edit 属性来自定义用于编辑代码的提示模板。Continue 使用 Handlebars 语法进行模板化。 编辑模板的可用变量:
  • {{{userInput}}} - 用户的编辑请求/指令
  • {{{language}}} - 代码的编程语言
  • {{{codeToEdit}}} - 正在编辑的代码
  • {{{prefix}}} - 编辑区域之前的内容
  • {{{suffix}}} - 编辑区域之后的内容
  • {{{supportsCompletions}}} - 模型是否支持 completions API
  • {{{supportsPrefill}}} - 模型是否支持预填充功能
示例
models:
  - name: My Custom Edit Template
    provider: openai
    model: gpt-4o
    promptTemplates:
      edit: |
        `Here is the code before editing:
        \`\`\`{{{language}}}
        {{{codeToEdit}}}
        \`\`\`

        Here is the edit requested:
        "{{{userInput}}}"

        Here is the code after editing:`