Skip to content

Commit c4145ae

Browse files
Merge pull request #737 from haesleinhuepf/edit-mode
Edit mode
2 parents a4123a2 + 743ce68 commit c4145ae

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/git_bob/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
__version__ = "0.23.1"
2-
1+
__version__ = "0.24.0"
32

43
__all__ = (
54
)

src/git_bob/_ai_github_utilities.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,16 @@ def create_or_modify_file(repository, issue, filename, branch_name, issue_summar
394394
## Your task
395395
Modify content of the file "{filename}" to solve the issue above.
396396
Keep your modifications absolutely minimal.
397-
Return the entire new file content, do not shorten it.
397+
If the modifications are long, return the entire new file content, do not shorten it.
398+
If the modification is short, return the original part you would like to replace and the new part you would like to replace it with.
399+
Do this in this format:
400+
401+
<original_part>
402+
Original (unmodified) part of the file content you would like to replace.
403+
</original_part>
404+
<new_part>
405+
New (modified) part of the file content you would like to replace it with.
406+
</new_part>
398407
"""
399408
else:
400409
print(filename, "will be created")
@@ -430,6 +439,12 @@ def create_or_modify_file(repository, issue, filename, branch_name, issue_summar
430439

431440
new_content, commit_message = split_content_and_summary(response)
432441

442+
if "<original_part>" in new_content and "<new_part>" in new_content:
443+
for part in new_content.split("</new_part>")[:-1]:
444+
original_part = part.split("<original_part>")[1].split("</original_part>")[0]
445+
new_part = part.split("<new_part>")[1]
446+
new_content = file_content.replace(original_part, new_part)
447+
433448
print("New file content", len(new_content), "\n------------\n", new_content[:200], "\n------------")
434449

435450
do_execute_notebook = False

0 commit comments

Comments
 (0)