mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 03:35:00 +00:00
refactor: move clipboard context functionality to commands.py
This commit is contained in:
parent
402940a215
commit
623770e24b
5 changed files with 54 additions and 52 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue