Skip to content

Commit e045c3c

Browse files
committed
feat: add documentation site
Signed-off-by: tylerslaton <[email protected]>
1 parent 2d161f5 commit e045c3c

30 files changed

+16091
-1
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ validate: tidy lint
3636

3737
ci: build
3838
./bin/gptscript ./scripts/ci.gpt
39-

docs/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

docs/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

docs/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

docs/docs/1-home.md

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
---
2+
title: Home
3+
slug: /
4+
---
5+
6+
## Overview
7+
8+
GPTScript is a new scripting language to automate your interaction with a Large Language Model (LLM), namely OpenAI. The ultimate goal is to create a fully natural language based programming experience. The syntax of GPTScript is largely natural language, making it very easy to learn and use.
9+
Natural language prompts can be mixed with traditional scripts such as bash and python or even external HTTP service
10+
calls. With GPTScript you can do just about anything like [plan a vacation](./examples/travel-agent.gpt),
11+
[edit a file](./examples/add-go-mod-dep.gpt), [run some SQL](./examples/sqlite-download.gpt), or [build a mongodb/flask app](./examples/hacker-news-headlines.gpt).
12+
13+
```yaml
14+
# example.gpt
15+
16+
Tools: sys.download, sys.exec, sys.remove
17+
18+
Download https://www.sqlitetutorial.net/wp-content/uploads/2018/03/chinook.zip to a
19+
random file. Then expand the archive to a temporary location as there is a sqlite
20+
database in it.
21+
22+
First inspect the schema of the database to understand the table structure.
23+
24+
Form and run a SQL query to find the artist with the most number of albums and output
25+
the result of that.
26+
27+
When done remove the database file and the downloaded content.
28+
```
29+
```
30+
$ gptscript ./example.gpt
31+
32+
OUTPUT:
33+
34+
The artist with the most number of albums in the database is Iron Maiden, with a total
35+
of 21 albums.
36+
```
37+
## Quick Start
38+
39+
### 1. Install the latest release
40+
41+
#### Homebrew (macOS and Linux)
42+
43+
```shell
44+
brew install gptscript-ai/tap/gptscript
45+
```
46+
47+
#### Install Script (macOS and Linux):
48+
49+
```shell
50+
curl https://get.gptscript.ai/install.sh | sh
51+
```
52+
53+
#### WinGet (Windows)
54+
55+
```shell
56+
winget install gptscript-ai.gptscript
57+
```
58+
59+
#### Manually
60+
61+
Download and install the archive for your platform and architecture from the [releases page](https://github.com/gptscript-ai/gptscript/releases).
62+
63+
### 2. Get an API key from [OpenAI](https://platform.openai.com/api-keys).
64+
65+
```shell
66+
export OPENAI_API_KEY="your-api-key"
67+
```
68+
69+
### 3. Run Hello World
70+
71+
```shell
72+
gptscript https://get.gptscript.ai/echo.gpt --input 'Hello, World!'
73+
74+
OUTPUT:
75+
76+
Hello, World!
77+
```
78+
The model used by default is `gpt-4-turbo-preview` and you must have access to that model in your OpenAI account.
79+
80+
### 4. Extra Credit: Examples and Run Debugging UI
81+
82+
Clone examples and run debugging UI
83+
```shell
84+
git clone https://github.com/gptscript-ai/gptscript
85+
cd gptscript/examples
86+
87+
# Run the debugging UI
88+
gptscript --server
89+
```
90+
91+
## How it works
92+
93+
***GPTScript is composed of tools.*** Each tool performs a series of actions similar to a function. Tools have available
94+
to them other tools that can be invoked similar to a function call. While similar to a function, the tools are
95+
primarily implemented with a natural language prompt. ***The interaction of the tools is determined by the AI model***,
96+
the model determines if the tool needs to be invoked and what arguments to pass. Tools are intended to be implemented
97+
with a natural language prompt but can also be implemented with a command or HTTP call.
98+
99+
### Example
100+
Below are two tool definitions, separated by `---`. The first tool does not require a name or description, but
101+
every tool after name and description are required. The first tool, has the parameter `tools: bob` meaning that the tool named `bob` is available to be called if needed.
102+
103+
```yaml
104+
tools: bob
105+
106+
Ask Bob how he is doing and let me know exactly what he said.
107+
108+
---
109+
name: bob
110+
description: I'm Bob, a friendly guy.
111+
args: question: The question to ask Bob.
112+
113+
When asked how I am doing, respond with "Thanks for asking "${question}", I'm doing great fellow friendly AI tool!"
114+
```
115+
Put the above content in a file named `bob.gpt` and run the following command:
116+
```shell
117+
$ gptscript bob.gpt
118+
119+
OUTPUT:
120+
121+
Bob said, "Thanks for asking 'How are you doing?', I'm doing great fellow friendly AI tool!"
122+
```
123+
Tools can be implemented by invoking a program instead of a natural language prompt. The below
124+
example is the same as the previous example but implements Bob using python.
125+
126+
```yaml
127+
Tools: bob
128+
129+
Ask Bob how he is doing and let me know exactly what he said.
130+
131+
---
132+
Name: bob
133+
Description: I'm Bob, a friendly guy.
134+
Args: question: The question to ask Bob.
135+
136+
#!python3
137+
138+
import os
139+
140+
print(f"Thanks for asking {os.environ['question']}, I'm doing great fellow friendly AI tool!")
141+
```
142+
143+
With these basic building blocks you can create complex scripts with AI interacting with AI, your local system, data,
144+
or external services.
145+
146+
## GPT File Reference
147+
148+
### Extension
149+
GPTScript files use the `.gpt` extension by convention.
150+
151+
### File Structure
152+
A GPTScript file has one or more tools in the file. Each tool is separated by three dashes `---` alone on a line.
153+
154+
```yaml
155+
Name: tool1
156+
Description: This is tool1
157+
158+
Do sample tool stuff.
159+
160+
---
161+
Name: tool2
162+
Description: This is tool2
163+
164+
Do more sample tool stuff.
165+
```
166+
167+
### Tool Definition
168+
169+
A tool starts with a preamble that defines the tool's name, description, args, available tools and additional parameters.
170+
The preamble is followed by the tool's body, which contains the instructions for the tool. Comments in
171+
the preamble are lines starting with `#` and are ignored by the parser. Comments are not really encouraged
172+
as the text is typically more useful in the description, argument descriptions or instructions.
173+
174+
```yaml
175+
Name: tool-name
176+
# This is a comment in the preamble.
177+
Description: Tool description
178+
# This tool can invoke tool1 or tool2 if needed
179+
Tools: tool1, tool2
180+
Args: arg1: The description of arg1
181+
182+
Tool instructions go here.
183+
```
184+
#### Tool Parameters
185+
186+
Tool parameters are key-value pairs defined at the beginning of a tool block, before any instructional text. They are specified in the format `key: value`. The parser recognizes the following keys (case-insensitive and spaces are ignored):
187+
188+
`Name`: The name of the tool.
189+
190+
`Model Name`: The OpenAI model to use, by default it uses "gpt-4-turbo-preview"
191+
192+
`Description`: The description of the tool. It is important that the properly describes the tool's purpose as the
193+
description is used by the LLM to determine if the tool is to be invoked.
194+
195+
`Internal Prompt`: Setting this to `false` will disable the built in system prompt for this tool. GPTScript includes a
196+
default system prompt to instruct the AI to behave more like a script engine and not a "helpful assistant."
197+
198+
`Tools`: A comma-separated list of tools that are available to be called by this tool. A tool can only call the tools
199+
that are defined here. A tool name can reference a name in the current file, or a file relative to the current directory
200+
of the tool file, a http(s) URL, or a file in GitHub using github.com/username/repo/file.gpt format. When referencing
201+
a file or URL the tool loaded is the first tool in the file. To reference a specific tool in a file or URL use the
202+
syntax `tool-name from file-or-url`.
203+
204+
`Args`: Arguments for the tool. Each argument is defined in the format `arg-name: description`. All arguments are essentially
205+
strings. No other type really exists as all input and output to tools is text based.
206+
207+
`Max Tokens`: Set to a number if you wish to limit the maximum number of tokens that can be generated by the LLM.
208+
209+
`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
210+
to inform the LLM to respond in some JSON structure.
211+
212+
`Temperature`: A floating-point number representing the temperature parameter. By default the temperature is 0. Set to a higher number to make the LLM more creative.
213+
214+
#### Tool Body
215+
216+
The tool body contains the instructions for the tool which can be a natural language prompt or
217+
a command to execute. Commands must start with `#!` followed by the interpreter (e.g. `#!/bin/bash`, `#!python3`)
218+
a text that will be placed in a file and passed to the interpreter. Arguments can be references in the instructions
219+
using the format `${arg1}`.
220+
221+
```yaml
222+
name: echo-ai
223+
description: A tool that echos the input
224+
args: input: The input
225+
226+
Just return only "${input}"
227+
228+
---
229+
name: echo-command
230+
description: A tool that echos the input
231+
args: input: The input
232+
233+
#!/bin/bash
234+
235+
echo "${input}"
236+
```
237+
238+
## Built in Tools
239+
240+
There are several built in tools to do basic things like read/write files, download http content and execute commands.
241+
Run `gptscript --list-tools` to list all the built-in tools.
242+
243+
## Examples
244+
245+
For more examples check out the [examples](examples) directory.
246+
247+
## Community
248+
249+
Join us on Discord: [![Discord](https://img.shields.io/discord/1204558420984864829?label=Discord)](https://discord.gg/9sSf4UyAMC)
250+
251+
## License
252+
253+
Copyright (c) 2023 [Acorn Labs, Inc.](http://acorn.io)
254+
255+
Licensed under the Apache License, Version 2.0 (the "License");
256+
you may not use this file except in compliance with the License.
257+
You may obtain a copy of the License at
258+
259+
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
260+
261+
Unless required by applicable law or agreed to in writing, software
262+
distributed under the License is distributed on an "AS IS" BASIS,
263+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
264+
See the License for the specific language governing permissions and
265+
limitations under the License.

docs/docs/tools/_category_.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Tools",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Explore the various tools on offer for gptscripts"
7+
}
8+
}

docs/docs/tools/image-generation.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Image Generation
2+
3+
## Overview
4+
5+
The `image-generation` tool leverages OpenAI's Dall-E model to convert textual descriptions into images. It offers a versatile approach to creating visual content, making it suitable for a wide range of applications, from content creation to design assistance.
6+
7+
For more information, check out the tool [here](https://github.com/gptscript-ai/image-generation)
8+
9+
## Usage
10+
To use the Image Generation too, you need to make sure that the OPENAI_API_KEY environment variable is set to your OpenAI API key. You can obtain an API key from the OpenAI platform if you don't already have one.
11+
12+
With that setup, you can use it in any GPTScript like so:
13+
14+
```
15+
tools: ./tool/image-generation, sys.write
16+
17+
Generate an image of a city skyline at night with a resolution of 512x512 pixels.
18+
19+
Write the resulting image to a file named "city_skyline.png".
20+
```

0 commit comments

Comments
 (0)