← Back to Blog

Implementing the attach files tool

In the last blog post I wrote about Gwenai's tools, what they are and how you can use them more effectively. While writing one of the tips I had an idea: attaching files through tools. Before today, if you wanted Gwenai to be able to see images for example, you would have to download them and attach them manually through the UI. But what if Gwenai could do this by itself, without the user's intervention? That would greatly increase automation capabilities since any model could just run the "attach files" tool by itself. This opens up cool possibilities, like letting Gwenai auto-attach images from a web search, making workflows even smoother. This blog is a short walkthrough of this newly implemented tool: attach_file_paths.

Implementing the tool was actually quite easy and only took about 20 minutes. The infrastructure was already there for attaching files via paths, so all I had to do was add the new tool to the UI, make it runnable and then write a simple function which takes a list of paths and returns attachments. Initially I accidentally forgot an 's' in the tool name so when I ran the tool it thought the tool was a custom-made one, instead of a builtin one and I kept getting "permission denied" errors. It was trying to execute the files in my shell instead of reading them. With that fixed everything worked smoothly. I quickly tested on Windows and Mac as well and it worked without problems.

Gwenai dashboard interface showing the new tool

The tool takes a list of file paths separated by new lines (\n) and attaches them all in the UI. If an error occurs, for example when trying to read a non-UTF8 file, the tool will return an error with a description that Gwenai and you can read. Here's what using the tool could look like:

<<< attach_file_paths
~/Downloads/ProgrammingEnvironment.png
~/projects/website/index.html
>>>

The tool is not enabled by default, so remember to enable it in your new projects (and old through the "Edit Project" view) if you want to use it.

Gwenai project interface showing the new tool enabled

Thank you for reading! If you haven't yet tried Gwenai, download it for free.