Skip to content

Commit bc83ec1

Browse files
authored
Merge pull request #83 from njhale/docs-vision
docs: add basic vision tool cookbook
2 parents 01583db + 99243ba commit bc83ec1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

docs/docs/101-cookbook/vision.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Vision
2+
3+
In this example, let's say that we want to create a `.gpt` script that uses vision to describe an image on the internet in a certain style.
4+
5+
1. Clone the vision tool repository from Github
6+
7+
```shell
8+
git clone https://github.com/gptscript-ai/vision
9+
```
10+
11+
2. Install the tool's dependencies
12+
13+
```shell
14+
npm install
15+
```
16+
17+
3. Create a file called `describe.gpt`.
18+
19+
```yaml
20+
Tools: sys.write, ./vision/tool.gpt
21+
Args: url: (required) URL of the image to describe.
22+
23+
Describe the image at ${url} as if you were the narrator of a Wes Anderson film and write it to a file named description.txt.
24+
```
25+
26+
4. Run the script.
27+
28+
```shell
29+
gptscript describe.gpt --url "https://github.com/gptscript-ai/vision/blob/main/examples/eiffel-tower.png?raw=true"
30+
```
31+
32+
## Recap
33+
34+
In this example, we have created a GPTScript that leverages the `vision` tool to describe an image at a given URL. We gave it some flexibility by specifying an argument `url` that the user can provide when running the script. We also gave the script a specific style to generate the description with.
35+
36+
Notable things to point out:
37+
38+
#### Tools
39+
40+
The `tools` directive was used here to reference the `vision` and the `sys.write` tools. GPTScript will know the tools availble to it and will use them when it sees fit in the script.
41+
42+
#### Args
43+
44+
We used the `args` directive to specify the `url` argument that the user can provide when running the script. This is a required argument and the user must provide it when running the script.
45+
46+
#### Interpolation
47+
48+
The `${url}` syntax can we used to reference the `url` argument in the script. This is a made-up syntax and can be replaced with any other syntax that you prefer. The LLM should be able to understand the syntax and use the argument in the script.

0 commit comments

Comments
 (0)