mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
Add system reminder to messages if available
This commit is contained in:
parent
4d4bfba965
commit
3d603f3579
3 changed files with 20 additions and 13 deletions
|
@ -123,8 +123,7 @@ class Coder:
|
|||
|
||||
kwargs = use_kwargs
|
||||
|
||||
for coder_class in coders.__all__:
|
||||
coder = getattr(coders, coder_class)
|
||||
for coder in coders.__all__:
|
||||
if hasattr(coder, 'edit_format') and coder.edit_format == edit_format:
|
||||
res = coder(main_model, io, **kwargs)
|
||||
res.original_kwargs = dict(kwargs)
|
||||
|
@ -779,7 +778,9 @@ class Coder:
|
|||
dict(role="assistant", content="Ok."),
|
||||
]
|
||||
|
||||
if self.gpt_prompts.system_reminder:
|
||||
main_sys += "\n" + self.fmt_system_prompt(self.gpt_prompts.system_reminder)
|
||||
|
||||
messages = [
|
||||
dict(role="system", content=main_sys),
|
||||
]
|
||||
|
@ -789,9 +790,13 @@ class Coder:
|
|||
messages += self.done_messages
|
||||
messages += self.get_files_messages()
|
||||
|
||||
|
||||
if self.gpt_prompts.system_reminder:
|
||||
reminder_message = [
|
||||
dict(role="system", content=self.fmt_system_prompt(self.gpt_prompts.system_reminder)),
|
||||
]
|
||||
else:
|
||||
reminder_message = []
|
||||
|
||||
# TODO review impact of token count on image messages
|
||||
messages_tokens = self.main_model.token_count(messages)
|
||||
|
@ -810,7 +815,7 @@ class Coder:
|
|||
|
||||
max_input_tokens = self.main_model.info.get("max_input_tokens")
|
||||
# Add the reminder prompt if we still have room to include it.
|
||||
if max_input_tokens is None or total_tokens < max_input_tokens:
|
||||
if max_input_tokens is None or total_tokens < max_input_tokens and self.gpt_prompts.system_reminder:
|
||||
if self.main_model.reminder_as_sys_msg:
|
||||
messages += reminder_message
|
||||
elif final["role"] == "user":
|
||||
|
@ -1520,3 +1525,9 @@ class Coder:
|
|||
# files changed, move cur messages back behind the files messages
|
||||
# self.move_back_cur_messages(self.gpt_prompts.files_content_local_edits)
|
||||
return True
|
||||
|
||||
def get_edits(self, mode="update"):
|
||||
return []
|
||||
|
||||
def apply_edits(self, edits):
|
||||
return
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class CoderPrompts:
|
||||
system_reminder = ""
|
||||
|
||||
files_content_gpt_edits = "I committed the changes with git hash {hash} & commit msg: {message}"
|
||||
|
||||
files_content_gpt_edits_no_repo = "I updated the files."
|
||||
|
|
|
@ -10,9 +10,3 @@ from .chat_prompts import ChatPrompts
|
|||
class ChatCoder(Coder):
|
||||
edit_format = "chat"
|
||||
gpt_prompts = ChatPrompts()
|
||||
|
||||
def get_edits(self, mode="update"):
|
||||
return
|
||||
|
||||
def apply_edits(self, edits):
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue