@@ -114,6 +114,16 @@ def params(self) -> Sequence[openai.types.chat.ChatCompletionToolParam]:
114114 },
115115 },
116116 ),
117+ self ._param (
118+ name = "delete_file" ,
119+ description = "Delete a file" ,
120+ inputs = {
121+ "path" : {
122+ "type" : "string" ,
123+ "description" : "Path of the file to be deleted" ,
124+ },
125+ },
126+ ),
117127 ]
118128
119129
@@ -125,12 +135,11 @@ def params(self) -> Sequence[openai.types.chat.ChatCompletionToolParam]:
125135 read the content of the relevant ones, and save the changes you suggest.
126136
127137 You should stop when and ONLY WHEN all the files you need to change have
128- been updated.
129-
130- If you stop for any reason before completing your task, explain why by
131- updating a REASON file before stopping. For example if you are missing some
132- information or noticed something inconsistent with the instructions, say so
133- there. DO NOT STOP without updating at least this file.
138+ been updated. If you stop for any reason before completing your task,
139+ explain why by updating a REASON file before stopping. For example if you
140+ are missing some information or noticed something inconsistent with the
141+ instructions, say so there. DO NOT STOP without updating at least this
142+ file.
134143"""
135144
136145
@@ -144,6 +153,9 @@ def _on_read_file(self, path: PurePosixPath, contents: str | None) -> V:
144153 def _on_write_file (self , path : PurePosixPath ) -> V :
145154 raise NotImplementedError ()
146155
156+ def _on_delete_file (self , path : PurePosixPath ) -> V :
157+ raise NotImplementedError ()
158+
147159 def _on_list_files (self , paths : Sequence [PurePosixPath ]) -> V :
148160 raise NotImplementedError ()
149161
@@ -159,6 +171,10 @@ def handle_function(self, function: Any) -> V:
159171 contents = inputs ["contents" ]
160172 self ._toolbox .write_file (path , contents )
161173 return self ._on_write_file (path )
174+ elif name == "delete_file" :
175+ path = PurePosixPath (inputs ["path" ])
176+ self ._toolbox .delete_file (path )
177+ return self ._on_delete_file (path )
162178 else :
163179 assert name == "list_files" and not inputs
164180 paths = self ._toolbox .list_files ()
@@ -210,6 +226,9 @@ def _on_read_file(self, path: PurePosixPath, contents: str | None) -> str:
210226 def _on_write_file (self , path : PurePosixPath ) -> None :
211227 return None
212228
229+ def _on_delete_file (self , path : PurePosixPath ) -> None :
230+ return None
231+
213232 def _on_list_files (self , paths : Sequence [PurePosixPath ]) -> str :
214233 joined = "\n " .join (f"* { p } " for p in paths )
215234 return f"Here are the available files: { joined } "
@@ -317,5 +336,8 @@ def _on_read_file(
317336 def _on_write_file (self , path : PurePosixPath ) -> _ToolOutput :
318337 return self ._wrap ("OK" )
319338
339+ def _on_delete_file (self , path : PurePosixPath ) -> _ToolOutput :
340+ return self ._wrap ("OK" )
341+
320342 def _on_list_files (self , paths : Sequence [PurePosixPath ]) -> _ToolOutput :
321343 return self ._wrap ("\n " .join ((str (p ) for p in paths )))
0 commit comments