编辑格式
Aider uses various “edit formats” to let LLMs edit source files. Different models work better or worse with different edit formats. Aider is configured to use the optimal format for most popular, common models. You can always force use of a specific edit format with the --edit-format
switch.
Aider 使用各种“编辑格式”让 LLM 编辑源文件。不同模型在不同编辑格式下的表现好坏不一。Aider 被配置为使用大多数流行、常见模型的最佳格式。您始终可以通过 --edit-format
开关强制使用特定的编辑格式。
whole
整体
The “whole” edit format is the simplest possible editing format. The LLM is instructed to return a full, updated copy of each source file that needs changes. While simple, it can be slow and costly because the LLM has to return the entire file even if just a few lines are edited.
“整体”编辑格式是最简单的编辑格式。LLM 被指示返回每个需要更改的源文件的完整更新副本。虽然简单,但可能会很慢且成本高,因为 LLM 必须返回整个文件,即使只编辑了几行。
The whole format expects the file path just before the fenced file content:
整个格式期望文件路径就在围栏文件内容之前:
show_greeting.py
```
import sys
def greeting(name):
print("Hey", name)
if __name__ == '__main__':
greeting(sys.argv[1])
```
diff
差异
The “diff” edit format asks the LLM to specify file edits as a series of search/replace blocks. This is an efficient format, because the model only needs to return parts of the file which have changes.
“差异”编辑格式要求 LLM 将文件编辑指定为一系列搜索/替换块。这是一种高效的格式,因为模型只需要返回有变化的文件部分。
Edits are formatted using a syntax similar to the git merge conflict resolution markings, with the file path right before a fenced block:
编辑使用类似于 git 合并冲突解决标记的语法格式化,文件路径位于围栏块之前:
mathweb/flask/app.py
```
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
diff-fenced
差异-围栏
The “diff-fenced” edit format is based on the diff format, but the file path is placed inside the fence. It is primarily used with the Gemini family of models, which often fail to conform to the fencing approach specified in the diff format.
“差异-围栏”编辑格式基于差异格式,但文件路径放置在围栏内。它主要用于 Gemini 系列模型,这些模型往往无法遵循差异格式中指定的围栏方法。
```
mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```...