refactor: move clipboard context functionality to commands.py

This commit is contained in:
Paul Gauthier 2024-12-05 20:41:40 -08:00 committed by Paul Gauthier (aider)
parent 402940a215
commit 623770e24b
5 changed files with 54 additions and 52 deletions

View file

@ -5,49 +5,3 @@ from .editor_editblock_prompts import EditorEditBlockPrompts
class EditorEditBlockCoder(EditBlockCoder):
edit_format = "editor-diff"
gpt_prompts = EditorEditBlockPrompts()
def format_chat_markdown(self):
chunks = self.format_chat_chunks()
markdown = ""
# Only include specified chunks in order
for messages in [chunks.repo, chunks.readonly_files, chunks.chat_files, chunks.cur]:
for msg in messages:
# Only include user messages
if msg["role"] != "user":
continue
content = msg["content"]
# Handle image/multipart content
if isinstance(content, list):
for part in content:
if part.get("type") == "text":
markdown += part["text"] + "\n\n"
else:
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" and self.gpt_prompts.system_reminder:
chunks.reminder = [
dict(
role="system",
content=self.fmt_system_prompt(self.gpt_prompts.system_reminder),
)
]
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