Toolkit.FileSystem

A collection of prebuilt tools for interacting with the file system. For safety reasons, the tools in this module are limited to working in the current working directory and its subdirectories.

# USAGE:
# Tool list to initialize the client
tools = [
    list_directory.tool, 
    list_file_tree.tool, 
    read_file_contents.tool, 
    write_file_contents.tool,
]
# Tool handler map is passed to Tools.handle_tool_calls!
tool_handler_map = Dict.from_list([
    (list_directory.name, listDirectory.handler),
    (list_file_tree.name, list_file_tree.handler),
    (read_file_contents.name, read_file_contents.handler),
    (write_file_contents.name, write_file_contents.handler),
])
client = Client.new { apiKey, model: "tool-capable/model", tools }
#...
messages = Chat.add_user_message(client, newMessage, {})
response = Http.send!(Chat.build_http_request(client, {}))?
with_tool_results = 
     Chat.update_messages(response, messages)?
    |> Tools.handle_tool_calls!(client toolHandlerMap, { max_model_calls: 5 })

list_directory : { name : Str, handler! : Str => Result Str , tool : Tool }

Expose name, handler and tool for listDirectory.

list_file_tree : { name : Str, handler! : Str => Result Str , tool : Tool }

Expose name, handler and tool for listFileTree.

This tool will allow the model to list the contents of a directory, and all subdirectories.

read_file_contents : { name : Str, handler! : Str => Result Str , tool : Tool }

Expose name, handler and tool for readFileContents.

This tool will allow the model to read the contents of a file.

write_file_contents : { name : Str, handler! : Str => Result Str , tool : Tool }

Expose name, handler and tool for writeFileContents.

This tool will allow the model to write content to a file.