This commit is contained in:
Paul Gauthier 2024-07-04 16:06:12 -03:00
parent fceaa0504c
commit af48cc3e4c
7 changed files with 180 additions and 47 deletions

View file

@ -75,6 +75,7 @@ class Coder:
edit_format=None,
io=None,
from_coder=None,
summarize_from_coder=True,
**kwargs,
):
from . import (
@ -108,7 +109,7 @@ class Coder:
# confused the new LLM. It may try and imitate it, disobeying
# the system prompt.
done_messages = from_coder.done_messages
if edit_format != from_coder.edit_format and done_messages:
if edit_format != from_coder.edit_format and done_messages and summarize_from_coder:
done_messages = from_coder.summarizer.summarize_all(done_messages)
# Bring along context from the old Coder
@ -550,18 +551,16 @@ class Coder:
files_reply = "Ok, any changes I propose will be to those files."
elif repo_content:
files_content = self.gpt_prompts.files_no_full_files_with_repo_map
files_reply = (
"Ok, based on your requests I will suggest which files need to be edited and then"
" stop and wait for your approval."
)
files_reply = self.gpt_prompts.files_no_full_files_with_repo_map_reply
else:
files_content = self.gpt_prompts.files_no_full_files
files_reply = "Ok."
files_messages += [
dict(role="user", content=files_content),
dict(role="assistant", content=files_reply),
]
if files_content:
files_messages += [
dict(role="user", content=files_content),
dict(role="assistant", content=files_reply),
]
images_message = self.get_images_message()
if images_message is not None:
@ -734,7 +733,8 @@ class Coder:
example_messages = []
if self.main_model.examples_as_sys_msg:
main_sys += "\n# Example conversations:\n\n"
if self.gpt_prompts.example_messages:
main_sys += "\n# Example conversations:\n\n"
for msg in self.gpt_prompts.example_messages:
role = msg["role"]
content = self.fmt_system_prompt(msg["content"])

View file

@ -28,6 +28,11 @@ Only include the files that are most likely to actually need to be edited.
Don't include files that might contain relevant context, just files that will need to be changed.
""" # noqa: E501
files_no_full_files_with_repo_map_reply = (
"Ok, based on your requests I will suggest which files need to be edited and then"
" stop and wait for your approval."
)
repo_content_prefix = """Here are summaries of some files present in my git repository.
Do not propose changes to these files, treat them as *read-only*.
If you need to edit any of these files, ask me to *add them to the chat* first.

View file

@ -29,3 +29,15 @@ Unless the question indicates otherwise, assume the user wants to use aider as a
example_messages = []
system_reminder = ""
files_content_prefix = """These are some files we have been discussing that we may want to edit after you answer my questions:
"""
files_no_full_files = "I am not sharing any files with you."
files_no_full_files_with_repo_map = ""
files_no_full_files_with_repo_map_reply = ""
repo_content_prefix = """Here are summaries of some files present in my git repository.
We may look at these in more detail after you answer my questions.
"""

View file

@ -656,6 +656,7 @@ class Commands:
io=self.io,
from_coder=self.coder,
edit_format="help",
summarize_from_coder=False,
)
user_msg = self.help.ask(args)
user_msg += """

View file

@ -5,8 +5,8 @@ import sys
import warnings
from pathlib import Path
from tqdm import tqdm
import importlib_resources
from tqdm import tqdm
from aider.dump import dump # noqa: F401
@ -14,16 +14,20 @@ warnings.simplefilter("ignore", category=FutureWarning)
def get_package_files():
website_files = importlib_resources.files('website')
for path in importlib_resources.files('website').iterdir():
if path.is_file() and path.name.endswith('.md'):
if not any(part.startswith(('OLD', 'tmp')) or part in ('examples', '_posts') for part in path.parts):
dump(path)
for path in importlib_resources.files("website").iterdir():
dump(path)
if path.is_file() and path.name.endswith(".md"):
if not any(
part.startswith(("OLD", "tmp")) or part in ("examples", "_posts")
for part in path.parts
):
yield str(path)
elif path.is_dir():
for subpath in path.rglob('*.md'):
if not any(part.startswith(('OLD', 'tmp')) or part in ('examples', '_posts') for part in subpath.parts):
dump(subpath)
for subpath in path.rglob("*.md"):
if not any(
part.startswith(("OLD", "tmp")) or part in ("examples", "_posts")
for part in subpath.parts
):
yield str(subpath)
@ -35,9 +39,6 @@ def fname_to_url(filepath):
docid = ""
if filepath.startswith("website/_includes/"):
pass
elif "HISTORY.html" in filepath:
# too much stale info
pass
elif filepath.startswith(website):
docid = filepath[len(website) :]
@ -73,8 +74,9 @@ def get_index():
nodes = []
for fname in tqdm(list(get_package_files())):
fname = Path(fname)
dump(fname)
doc = Document(
text=importlib_resources.files('website').joinpath(fname).read_text(),
text=importlib_resources.files("website").joinpath(fname).read_text(),
metadata=dict(
filename=fname.name,
extension=fname.suffix,