feat: add support for the new commit_prompt arg to override prompts.commit_system

The GitRepo class in the aider/repo.py file has been updated to support a new `commit_prompt` argument. This allows overriding the default `prompts.commit_system` when generating commit messages.

The changes include:

1. Adding the `commit_prompt` parameter to the `__init__` method of the `GitRepo` class.
2. Storing the `commit_prompt` value in the `self.commit_prompt` attribute.
3. Modifying the `get_commit_message` method to use the `self.commit_prompt` value if it's provided, otherwise falling back to the default `prompts.commit_system`.

This change provides more flexibility in customizing the commit message generation process, allowing users to provide their own custom prompts if needed.
This commit is contained in:
Paul Gauthier (aider) 2024-07-31 09:47:49 -03:00
parent 4dfdddf0d9
commit 1275171b90

View file

@ -26,6 +26,7 @@ class GitRepo:
attribute_author=True,
attribute_committer=True,
attribute_commit_message=False,
commit_prompt=None,
):
self.io = io
self.models = models
@ -33,6 +34,7 @@ class GitRepo:
self.attribute_author = attribute_author
self.attribute_committer = attribute_committer
self.attribute_commit_message = attribute_commit_message
self.commit_prompt = commit_prompt
if git_dname:
check_fnames = [git_dname]
@ -154,8 +156,9 @@ class GitRepo:
content += context + "\n"
content += diffs
system_content = self.commit_prompt or prompts.commit_system
messages = [
dict(role="system", content=prompts.commit_system),
dict(role="system", content=system_content),
dict(role="user", content=content),
]