Tools
Python functions the AI can use, in Chat, in Code and from apps through the API. Each tool is a file in your tools folder, so you can also write them in your own editor or share them.
Writing a tool
- Define
run. Its docstring's first part is what the AI reads to decide when to use the tool; describe each input underArgs:. - Type hints become the inputs:
str,int,float,bool,list[str],dictandLiteral["a", "b"]for a fixed choice. Inputs with a default are optional. - Return text, or anything JSON can hold. What the tool prints is shown to you when testing, not to the AI.
- Need a package? Add a
# /// scriptblock at the top withdependencies = ["requests"], as foruv run. - Tools run in a sandbox: they can reach the internet, but not your files or local network, and have a minute to finish. Trust one you wrote yourself to run directly on this computer.