|
| 1 | +--- |
| 2 | +description: GPTScript Tool Files |
| 3 | +globs: *.gpt |
| 4 | +alwaysApply: true |
| 5 | +--- |
| 6 | +# GPTScript Tool File Format Rules |
| 7 | + |
| 8 | +## File Extension |
| 9 | + |
| 10 | +- Files with extension `.gpt` are GPTScript tool files |
| 11 | +- These files define tools that can be provided to a large language model for execution |
| 12 | + |
| 13 | +## File Structure |
| 14 | + |
| 15 | +Each tool definition in the file follows this structure: |
| 16 | + |
| 17 | +1. Preamble: |
| 18 | + - Contains tool directives. Here are some common ones: |
| 19 | + - `Name`: The name of the tool |
| 20 | + - `Description`: A description of what the tool does |
| 21 | + - `Param`: Parameters the tool accepts (optional) |
| 22 | + - `Share Tools`: Other tools this tool can use (optional) |
| 23 | + - `Share Context`: Context this tool shares with other tools (optional) |
| 24 | + - `Tools`: External tools this tool can use (optional) |
| 25 | + - `Credential`: Path to credential file (optional) |
| 26 | + - `Metadata`: Additional metadata (optional) |
| 27 | + |
| 28 | +2. Command/Prompt: |
| 29 | + - Separated from preamble by a blank line |
| 30 | + - Contains the actual command or prompt to execute |
| 31 | + - Can be a shell command or a prompt for the language model |
| 32 | + |
| 33 | +3. Tool Separation: |
| 34 | + - Each tool definition is separated by `---` |
| 35 | + |
| 36 | +## Special Sections |
| 37 | + |
| 38 | +- Context tool definitions start with `Type: context` |
| 39 | +- Metadata sections can be defined using `!metadata:*:key` syntax |
| 40 | + - You don't need to worry about these, and can just ignore them |
| 41 | + |
| 42 | +## Example Structure |
| 43 | + |
| 44 | +``` |
| 45 | +Name: Tool Name |
| 46 | +Description: Tool description |
| 47 | +Param: param1: description |
| 48 | +Share Tools: Tool1, Tool2 |
| 49 | +Credential: ./credential |
| 50 | + |
| 51 | +#!/usr/bin/env command |
| 52 | + |
| 53 | +--- |
| 54 | +Name: Another Tool |
| 55 | +Description: Another tool description |
| 56 | +Param: param1: description |
| 57 | + |
| 58 | +# Prompt or command here |
| 59 | +``` |
| 60 | + |
| 61 | +## Context Tools |
| 62 | + |
| 63 | +A context tool is a way to provide additional prompting to the LLM. Any tool with `Type: context` and any tool that is included in another tool like |
| 64 | +`Context: tool name` is a context tool, and will be called automatically for the LLM to provide helpful information. |
| 65 | + |
| 66 | +## Tool Directives |
| 67 | + |
| 68 | +Here is the full list of tool directives: |
| 69 | + |
| 70 | +| Key | Description | |
| 71 | +|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------| |
| 72 | +| `Name` | The name of the tool. | |
| 73 | +| `Description` | The description of the tool. It is important that this properly describes the tool's purpose as the description is used by the LLM. | |
| 74 | +| `Tools` | A comma-separated list of tools that are available to be called by this tool. | |
| 75 | +| `Parameter` / `Param` | Parameters for the tool. Each parameter is defined in the format `param-name: description`. | |
| 76 | +| `JSON Response` | Setting to `true` will cause the LLM to respond in a JSON format. If you set true you must also include instructions in the tool. | |
| 77 | +| `Credential` | Credential tool to call to set credentials as environment variables before doing anything else. One per line. | |
| 78 | +| `Share Tools` | A comma-separated list of tools that are shared by the tool. | |
| 79 | +| `Context` | A comma-separated list of context tools available to the tool. | |
| 80 | +| `Share Context` | A comma-separated list of context tools shared by this tool with any tool including this tool in its context. | |
| 81 | + |
| 82 | +## Helpful Information |
| 83 | + |
| 84 | +- When a tool is executed, all parameter values become environment variables in all caps. For example, if the value of a param called `color` is set to `blue`, then in the environment, the tool will have `COLOR=blue`. |
| 85 | + |
| 86 | +## Tool Bundles |
| 87 | + |
| 88 | +- A tool bundle is a tool with `Metadata: bundle: true` |
| 89 | +- Tool bundles MUST include all tools defined in their file in their `Share Tools` list |
| 90 | +- This ensures that when other tools include the bundle, they get access to all tools in the bundle |
| 91 | + |
| 92 | +## Best Practices |
| 93 | + |
| 94 | +1. Each tool should have a clear, descriptive name |
| 95 | +2. Descriptions should be detailed and explain the tool's purpose |
| 96 | +3. Parameters should be clearly documented with descriptions |
| 97 | +4. Use appropriate sharing of tools and context to enable tool composition |
| 98 | + |
| 99 | +## Canonical Examples |
| 100 | + |
| 101 | +See [tool.gpt](mdc:slack/tool.gpt), [tool.gpt](mdc:github/tool.gpt), and [tool.gpt](mdc:google/gmail/tool.gpt) for good examples of tool files. |
0 commit comments