@@ -394,7 +394,16 @@ def create_or_modify_file(repository, issue, filename, branch_name, issue_summar
394394## Your task
395395Modify content of the file "{ filename } " to solve the issue above.
396396Keep 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