You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/03-tools/01-using.md
+21-6Lines changed: 21 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -35,19 +35,34 @@ Select a number at random between 1 and 100 and return only the number.
35
35
```
36
36
37
37
### External Tools
38
+
You can refer to GPTScript tool files that are served on the web or stored locally. This is useful for sharing tools across multiple scripts or for using tools that are not part of the core GPTScript distribution.
38
39
39
-
This is where the real power of GPTScript starts to become evident. For this example lets use the external [image-generation](https://github.com/gptscript-ai/image-generation) and [search](https://github.com/gptscript-ai/search) tools to generate an image and then search the web for similar images.
40
+
```yaml
41
+
tools: https://get.gptscript.ai/echo.gpt
42
+
43
+
Echo the phrase "Hello, World!".
44
+
```
45
+
46
+
Or, if the file is stored locally in "echo.gpt":
47
+
48
+
```yaml
49
+
tools: echo.gpt
50
+
51
+
Echo the phrase "Hello, World!".
52
+
```
53
+
54
+
You can also refer to OpenAPI definition files as though they were GPTScript tool files. GPTScript will treat each operation in the file as a separate tool. For more details, see [OpenAPI Tools](03-openapi.md).
40
55
41
-
:::note
42
-
There will be better packaging and distribution for external tools in the future. For now, this assumes you have the tools cloned locally and are pointing to their repos directly.
43
-
:::
56
+
### Packaged Tools on GitHub
57
+
GPTScript tools can be packaged and shared on GitHub, and referred to by their GitHub URL. For example:
Generate an image of a city skyline at night and write the resulting image to a file called city_skyline.png.
49
63
50
64
Take this image and write a description of it in the style of pirate.
51
65
```
52
66
53
-
External tools are tools that are defined by a `tool.gpt` file in their root directory. They can be imported into a GPTScript by specifying the path to the tool's root directory.
67
+
When this script is run, GPTScript will locally clone the referenced GitHub repos and run the tools referenced inside them.
68
+
For more info on how this works, see [Authoring Tools](02-authoring.md).
List all the pets. After you get a response, create a new pet named Mark. He is a lizard.
17
+
```
18
+
19
+
You can also use a local file path instead of a URL.
20
+
21
+
## Servers
22
+
23
+
GPTScript will look at the top-level `servers` array in the file and choose the first HTTPS server it finds.
24
+
If no HTTPS server exists, it will choose the first HTTP server. Other protocols (such as WSS) are not yet supported.
25
+
26
+
GPTScript will also handle path- and operation-level server overrides, following the same logic of choosing the first HTTPS server it finds,
27
+
or the first HTTP server if no HTTPS server exists in the array.
28
+
29
+
Additionally, GPTScript can handle variables in the server name. For example, this:
30
+
31
+
```yaml
32
+
servers:
33
+
- url: '{server}/v1'
34
+
variables:
35
+
server:
36
+
default: https://api.example.com
37
+
```
38
+
39
+
Will be resolved as `https://api.example.com/v1`.
40
+
41
+
## Authentication
42
+
43
+
GPTScript currently ignores any security schemes and authentication/authorization information in the OpenAPI definition file. This might change in the future.
44
+
45
+
For now, the only supported type of authentication is bearer tokens. GPTScript will look for a special environment variable based
46
+
on the hostname of the server. It looks for the format `GPTSCRIPT_<HOST>_BEARER_TOKEN`, where `<HOST>` is the hostname, but in all caps and
47
+
dots are replaced by underscores. For example, if the server is `https://api.example.com`, GPTScript will look for an environment variable
48
+
called `GPTSCRIPT_API_EXAMPLE_COM_BEARER_TOKEN`. If it finds one, it will use it as the bearer token for all requests to that server.
49
+
50
+
:::note
51
+
GPTScript will not look for bearer tokens if the server uses HTTP instead of HTTPS.
52
+
:::
53
+
54
+
## MIME Types and Request Bodies
55
+
56
+
In OpenAPI definitions, request bodies are described with a MIME type. Currently, GPTScript supports these MIME types:
57
+
- `application/json`
58
+
- `text/plain`
59
+
- `multipart/form-data`
60
+
61
+
GPTScript will return an error when parsing the OpenAPI definition if it finds a request body that does not specify
0 commit comments