mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
Roughed in updated sys msg for whole format
This commit is contained in:
parent
976f84bac5
commit
f005404ec0
3 changed files with 29 additions and 10 deletions
|
@ -273,7 +273,7 @@ class Coder:
|
|||
]
|
||||
if self.abs_fnames:
|
||||
files_messages += [
|
||||
dict(role="system", content=self.gpt_prompts.system_reminder),
|
||||
dict(role="system", content=self.fmt_system_reminder()),
|
||||
]
|
||||
|
||||
return files_messages
|
||||
|
@ -355,6 +355,25 @@ class Coder:
|
|||
|
||||
return self.send_new_user_message(inp)
|
||||
|
||||
num_ticks = 4
|
||||
|
||||
def fmt_system_reminder(self):
|
||||
prompt = self.gpt_prompts.system_reminder
|
||||
num_ticks = self.num_ticks
|
||||
|
||||
explain = f"""
|
||||
You *MUST* use {num_ticks} backticks, because some files contain {num_ticks-1} backticks already!"""
|
||||
|
||||
fence = "`" * num_ticks
|
||||
|
||||
prompt = prompt.format(
|
||||
num_ticks=num_ticks,
|
||||
fence=fence,
|
||||
num_ticks_explanation=explain,
|
||||
)
|
||||
|
||||
return prompt
|
||||
|
||||
def send_new_user_message(self, inp):
|
||||
self.cur_messages += [
|
||||
dict(role="user", content=inp),
|
||||
|
@ -362,7 +381,7 @@ class Coder:
|
|||
|
||||
main_sys = self.gpt_prompts.main_system
|
||||
if self.main_model.max_context_tokens > 4 * 1024:
|
||||
main_sys += "\n" + self.gpt_prompts.system_reminder
|
||||
main_sys += "\n" + self.fmt_system_reminder()
|
||||
|
||||
messages = [
|
||||
dict(role="system", content=main_sys),
|
||||
|
|
|
@ -14,19 +14,19 @@ Once you understand the request you MUST:
|
|||
3. If changes are needed, output a copy of each file that needs changes.
|
||||
"""
|
||||
|
||||
system_reminder = """
|
||||
To return code you MUST use this *file listing* format:
|
||||
system_reminder = """To return code you MUST use this *file listing* format:
|
||||
|
||||
path/to/filename.js
|
||||
```javascript
|
||||
{fence}javascript
|
||||
// entire file content goes in the
|
||||
// triple backticked fenced block
|
||||
```
|
||||
{fence}
|
||||
|
||||
Every *file listing* MUST use this format:
|
||||
- First line: the filename with any required path!
|
||||
- Second line: opening triple backtick fence with the correct code language.
|
||||
- Final line: closing triple backtick fence.
|
||||
- Second line: opening {num_ticks} backtick fence with the correct code language.
|
||||
- Final line: closing {num_ticks} backtick fence.
|
||||
{num_ticks_explanation}
|
||||
|
||||
To suggest changes to a file you MUST return a *file listing* that contains the entire content of the file.
|
||||
Create a new file you MUST return a *file listing* which includes an appropriate filename, including any required path.
|
||||
|
|
|
@ -6,7 +6,7 @@ from .dump import dump # noqa: F401
|
|||
def quoted_file(fname, display_fname, number=False):
|
||||
prompt = "\n"
|
||||
prompt += display_fname
|
||||
prompt += "\n```\n"
|
||||
prompt += "\n````\n"
|
||||
file_content = Path(fname).read_text()
|
||||
lines = file_content.splitlines()
|
||||
for i, line in enumerate(lines, start=1):
|
||||
|
@ -14,7 +14,7 @@ def quoted_file(fname, display_fname, number=False):
|
|||
prompt += f"{i:4d} "
|
||||
prompt += line + "\n"
|
||||
|
||||
prompt += "```\n"
|
||||
prompt += "````\n"
|
||||
return prompt
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue