File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,21 @@ async def edit_file_contents(
401
401
"suggestion" : "delete" ,
402
402
}
403
403
404
+ # Set suggestions for alternative tools
405
+ suggestion = None
406
+ hint = None
407
+ if not os .path .exists (file_path ) or not current_content :
408
+ suggestion = "append"
409
+ hint = "For new or empty files, please consider using append_text_file_contents instead"
410
+ elif is_insertion :
411
+ if start_zero >= len (lines ):
412
+ suggestion = "append"
413
+ hint = "For adding content at the end of file, please consider using append_text_file_contents instead"
414
+ else :
415
+ suggestion = "insert"
416
+ hint = "For inserting content within file, please consider using insert_text_file_contents instead"
417
+
418
+ # Prepare the content
404
419
new_content = contents if contents .endswith ("\n " ) else contents + "\n "
405
420
new_lines = new_content .splitlines (keepends = True )
406
421
@@ -424,6 +439,8 @@ async def edit_file_contents(
424
439
"result" : "ok" ,
425
440
"file_hash" : new_hash ,
426
441
"reason" : None ,
442
+ "suggestion" : suggestion ,
443
+ "hint" : hint ,
427
444
}
428
445
429
446
except FileNotFoundError :
You can’t perform that action at this time.
0 commit comments