|
1 | 1 | # Authoring Tools
|
2 | 2 |
|
3 |
| -You can author your own tools for your use or to share with others. The process for authoring a tool is as simple as creating a `tool.gpt` file in the root directory of your project. This file is itself a GPTScript that defines the tool's name, description, and what it should do. |
| 3 | +You can author your own tools for your use or to share with others. |
| 4 | +The process for authoring a tool is as simple as creating a `tool.gpt` file in the root directory of your project. |
| 5 | +This file is itself a GPTScript that defines the tool's name, description, and what it should do. |
4 | 6 |
|
5 | 7 | Here's an example of the `tool.gpt` file for the `image-generation` tool:
|
6 | 8 |
|
7 |
| -```yaml |
8 |
| -description: I am a tool that can generate images based on arguments that are sent to me. I return a list of URLs to the generated images. |
| 9 | +``` |
| 10 | +description: Generates images based on the specified parameters and returns a list of URLs to the generated images. |
9 | 11 | args: prompt: (required) The text prompt based on which the GPT model will generate a response
|
10 |
| -args: model: (optional) The model to use for image generation. Defaults to "dall-e-3". |
11 | 12 | args: size: (optional) The size of the image to generate, format WxH (e.g. 1024x1024). Defaults to 1024x1024.
|
12 | 13 | args: quality: (optional) The quality of the generated image. Allowed values are "standard" or "hd". Default is "standard".
|
13 | 14 | args: number: (optional) The number of images to generate. Defaults to 1.
|
14 | 15 |
|
15 |
| -#!/usr/bin/env python3 ./cli.py --prompt="${prompt}" --model="${model}" --size="${size}" --quality="${quality}" --number="${number}" |
| 16 | +#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/cli.py --prompt="${prompt}" --size="${size}" --quality="${quality}" --number="${number}" |
16 | 17 | ```
|
17 | 18 |
|
18 |
| -At the bottom you'll notice a shebang line that specifies the command to run when the tool is invoked. This is the exact command that will be executed when the tool is used in a GPTScript. Doing this with tools allows for a high degree of reliability that the tool would not otherwise have. |
| 19 | +At the bottom you'll notice a shebang (`#!/usr/bin/env ...`) line that specifies the command to run when the tool is invoked. This is the exact command that will be executed when the tool is used in a GPTScript. |
| 20 | +If there is no shebang line, then it will be treated as natural language for the LLM to process. |
19 | 21 |
|
20 | 22 | :::tip
|
21 |
| -Every arg becomes an environment variable when the tool is invoked. |
| 23 | +Every arg becomes an environment variable when the tool is invoked. So instead of accepting args using flags like `--size="${size}", your program can just read the `size` environment variable. |
22 | 24 | :::
|
23 | 25 |
|
24 | 26 | ## Binary Tools
|
|
0 commit comments