mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
fix: add empty list check before accessing last chat chunk
This commit is contained in:
parent
8f57186945
commit
22fc961dc0
1 changed files with 17 additions and 0 deletions
|
@ -29,3 +29,20 @@ class EditorEditBlockCoder(EditBlockCoder):
|
|||
markdown += content + "\n\n"
|
||||
|
||||
return markdown.strip()
|
||||
|
||||
def format_chat_chunks(self):
|
||||
chunks = super().format_chat_chunks()
|
||||
# Only add reminder if there are current messages
|
||||
if chunks.cur:
|
||||
final = chunks.cur[-1]
|
||||
if self.main_model.reminder == "sys":
|
||||
chunks.reminder = self.reminder_message
|
||||
elif self.main_model.reminder == "user" and final["role"] == "user":
|
||||
# stuff it into the user message
|
||||
new_content = (
|
||||
final["content"]
|
||||
+ "\n\n"
|
||||
+ self.fmt_system_prompt(self.gpt_prompts.system_reminder)
|
||||
)
|
||||
chunks.cur[-1] = dict(role=final["role"], content=new_content)
|
||||
return chunks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue