Skip to content

Commit

Permalink
Merge pull request gpt-engineer-org#838 from cfytrok/patch-1
Browse files Browse the repository at this point in the history
Add no occurrences warning on edit files
  • Loading branch information
TheoMcCabe authored Nov 5, 2023
2 parents 92e4f0e + a558008 commit 3be1c37
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gpt_engineer/core/chat_to_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ def apply_edits(edits: List[Edit], workspace: FileRepository):
)
workspace[filename] = edit.after # new file
else:
if workspace[filename].count(edit.before) > 1:
occurrences_cnt = workspace[filename].count(edit.before)
if occurrences_cnt == 0:
logger.warn(
f"While applying an edit to `{filename}`, the code block to be replaced was not found. No instances will be replaced."
)
if occurrences_cnt > 1:
logger.warn(
f"While applying an edit to `{filename}`, the code block to be replaced was found multiple times. All instances will be replaced."
)
Expand Down

0 comments on commit 3be1c37

Please sign in to comment.