Package com.embabel.agent.tools.file
Interface FileWriteTools
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.support.SelfToolCallbackPublisher,com.embabel.agent.core.ToolCallbackPublisher,com.embabel.agent.core.ToolCallbackSpec,com.embabel.agent.tools.DirectoryBased,com.embabel.agent.tools.file.FileAccessLog,com.embabel.agent.tools.file.FileChangeLog
public interface FileWriteTools implements DirectoryBased, FileAccessLog, FileChangeLog, SelfToolCallbackPublisher
All file modifications must go through this interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classFileWriteTools.Companion
-
Method Summary
Modifier and Type Method Description List<String>getPathsAccessed()StringcreateFile(String path, String content)Create a file at the relative path under the root PathcreateFile(String path, String content, Boolean overwrite)Create a file with the given content. StringeditFile(String path, @ToolParam(description = "content to replace") String oldContent, @ToolParam(description = "replacement content") String newContent)StringcreateDirectory(String path)StringappendFile(String path, String content)UnitappendToFile(String path, String content, Boolean createIfNotExists)Append content to a file, creating it if it doesn't exist. Stringdelete(String path)-
Methods inherited from class com.embabel.agent.tools.file.FileChangeLog
flushChanges, getChanges, recordChange -
Methods inherited from class com.embabel.agent.tools.DirectoryBased
getRoot -
Methods inherited from class com.embabel.agent.api.common.support.SelfToolCallbackPublisher
getToolCallbacks -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getPathsAccessed
List<String> getPathsAccessed()
-
createFile
@Tool(description = "Create a file with the given content") String createFile(String path, String content)
Create a file at the relative path under the root
-
createFile
Path createFile(String path, String content, Boolean overwrite)
Create a file with the given content.
- Parameters:
path- the relative path to create the file atcontent- the content to write to the fileoverwrite- if true, overwrite the file if it already exists- Returns:
the path to the created file
-
editFile
@Tool(description = "Edit the file at the given location. Replace oldContent with newContent. oldContent is typically just a part of the file. e.g. use it to replace a particular method to add another method") String editFile(String path, @ToolParam(description = "content to replace") String oldContent, @ToolParam(description = "replacement content") String newContent)
-
createDirectory
@Tool(description = "Create a directory at the given path") String createDirectory(String path)
-
appendFile
@Tool(description = "Append content to an existing file. The file must already exist.") String appendFile(String path, String content)
-
appendToFile
Unit appendToFile(String path, String content, Boolean createIfNotExists)
Append content to a file, creating it if it doesn't exist. If create is true, the file will be created if it doesn't exist. If createIfNotExists is false, an exception will be thrown if the file doesn't exist.
-
-
-
-