|
1 |
| -# README for GPT File Syntax |
| 1 | +# README.md for GPTscript Project |
2 | 2 |
|
3 |
| -## Overview |
4 |
| -GPT files found in this project use a custom syntax to describe various shell tools and their respective functionalities. Each file contains definitions for tools including their names, descriptions, arguments, and executable code. Below is an explanation of the syntax based on the contents of the GPT files reviewed (`./describe.gpt`, `./summarize-syntax.gpt`, `./tables.gpt`). |
| 3 | +## Project Description |
5 | 4 |
|
6 |
| -## Syntax Description |
| 5 | +This project utilizes `GPTscript`, a powerful scripting tool that leverages OpenAI's GPT plugins to execute tasks specified in `.gpt` files. These scripts can combine traditional scripting with GPT's AI capabilities to automate complex workflows, parse information, and more. |
7 | 6 |
|
8 |
| -### General Format |
9 |
| -GPT files follow a structured format that includes a preamble (indicating available tools), followed by metadata (descriptions of each tool), and Bash script examples for the tool's operation. |
| 7 | +## Usage |
10 | 8 |
|
11 |
| -Here's the general layout of a GPT file definition: |
12 |
| -``` |
13 |
| -Tools: <tool_list> |
14 |
| -<empty_line> |
15 |
| ---- (3 hyphens to separate each tool definition) |
16 |
| -name: <tool_name> |
17 |
| -description: <description_of_tool> |
18 |
| -arg: <argument_description> (Optional and re-occurring) |
19 |
| -<empty_line> |
20 |
| -<executable_code_block> |
21 |
| -``` |
| 9 | +The primary command used to run GPT scripts is `gptscript`, which can be invoked with various flags to control the script execution. A typical usage pattern looks like this: |
22 | 10 |
|
23 |
| -### Tool Definition Header |
24 |
| -A tool definition always starts with three hyphens (`---`). This is a separator used to distinguish between different tool descriptions within the file. |
| 11 | +```bash |
| 12 | +gptscript [flags] PROGRAM_FILE [INPUT...] |
| 13 | +``` |
25 | 14 |
|
26 |
| -### Name |
27 |
| -The `name` field defines the name of the tool. It is used to invoke a specific functionality. |
| 15 | +Where `PROGRAM_FILE` is the script to be executed, optionally followed by `INPUT` arguments to pass into the script. |
28 | 16 |
|
29 |
| -### Description |
30 |
| -The `description` field provides a concise explanation of what the tool does. |
| 17 | +## GPT File Syntax |
31 | 18 |
|
32 |
| -### Arguments |
33 |
| -The `arg` fields describe the arguments that the tool accepts. Each argument is paired with a brief description. Argument definitions are optional and can be repeated if a tool accepts multiple arguments. |
| 19 | +GPT script files (`*.gpt`) follow a syntax which allows for defining tools, their descriptions, arguments, and embedded traditional scripting codes. Here's a breakdown of the syntax: |
34 | 20 |
|
35 |
| -### Executable Code Block |
36 |
| -Following the metadata, an executable code block is provided. It is written in Bash and contains the script to execute the tool's functionality. |
| 21 | +- `tools:` Followed by the tool names to be used. |
| 22 | +- `name:` Defines the tool's name. |
| 23 | +- `description:` Describes what the tool does. |
| 24 | +- `args:` Lists arguments the tool accepts, describing the expected input. |
| 25 | +- `tools:` Below the main tool definition, you can specify other tools used by this tool. |
| 26 | +- A line containing `---` signifies the separation between tool metadata and the script code itself. |
37 | 27 |
|
38 |
| -### Examples |
39 |
| -Here are examples extracted from the GPT files which follow the syntax described: |
| 28 | +## Example `.gpt` Files and Their Syntax |
40 | 29 |
|
41 |
| -#### From `./describe.gpt` |
42 |
| -``` |
43 |
| ---- |
44 |
| -name: ls |
45 |
| -description: Recursively lists all go files |
| 30 | +The repository contains several example `.gpt` files, such as: |
46 | 31 |
|
47 |
| -#!/bin/bash |
48 |
| -
|
49 |
| -find . -name '*.go' |
50 |
| -``` |
51 |
| -#### From `./summarize-syntax.gpt` |
52 |
| -``` |
53 |
| ---- |
54 |
| -name: cat |
55 |
| -description: Reads the contents of a file |
56 |
| -arg: file: The filename to read |
| 32 | +- `describe.gpt`: Provides functionalities for working with Go files, with tools like `ls`, `count`, `summarize`, and `compare`. |
| 33 | +- `echo.gpt`: A simple script that echoes the provided input. |
| 34 | +- `fib.gpt`: An example demonstrating a recursive function `myfunction`. |
| 35 | +- `git-commit.gpt`: Automates the creation of a well-formed git commit message. |
| 36 | +- `helloworld.gpt`: A basic script outputs the traditional "hello world" message. |
| 37 | +- `summarize-syntax.gpt`: Meta-script for generating documentation based on `.gpt` files in a directory. |
| 38 | +- `tables.gpt`: Using SQLite, identifies the table in a database with the most rows. |
57 | 39 |
|
58 |
| -#!/bin/bash |
59 |
| -
|
60 |
| -cat ${FILE} </dev/null |
61 |
| -``` |
62 |
| -#### From `./tables.gpt` |
63 |
| -``` |
64 |
| ---- |
65 |
| -Name: sqlite |
66 |
| -Description: The sqlite command line program ... to run sqlite command or SQL statements against a database. |
67 |
| -Arg: databaseFile: The filename of the database to open |
68 |
| -Arg: cmd: The sqlite command or sql statement to run. |
69 |
| -
|
70 |
| -#!/bin/bash |
71 |
| -
|
72 |
| -sqlite3 ${DATABASEFILE} -cmd "${CMD}" </dev/null |
73 |
| -``` |
| 40 | +## gptscript Command Help |
74 | 41 |
|
75 |
| -## Additional Observations |
76 |
| -- The fields and code block are separated by a new line. |
77 |
| -- The arguments are indicated as `arg: argument_name: argument_description`. |
78 |
| -- The executable code is introduced with a `#!/bin/bash` shebang line and is expected to replace the argument placeholders (`${NAME}`) with actual values during execution. |
| 42 | +The help output for `gptscript` provides vital information on how to use the command along with the available flags. Here's an abbreviated listing of the flags: |
79 | 43 |
|
80 |
| -Please note that this description of the syntax is based on the provided examples and may not cover variations which are not included in those files. Additional GPT files may include diverse structures and should be reviewed to check for consistency with this syntax. |
| 44 | +- `--assemble`: Assemble tool to a single artifact, with output specified by `--output`. |
| 45 | +- `--cache`, `--cache-dir`: Controls caching behavior and cache directory location. |
| 46 | +- `--debug`: Enable debug logging. |
| 47 | +- `--help`: Displays help information for `gptscript`. |
| 48 | +- `--input`: Specify an input file or stdin. |
| 49 | +- `--list-models`, `--list-tools`: Lists available models or built-in tools. |
| 50 | +- `--openai-api-key`: Specifies the OpenAI API key to use. |
| 51 | +- `--output`: Saves output to a specified file. |
| 52 | +- `--quiet`: Suppresses output logging. |
| 53 | +- `--sub-tool`: Selects a specific sub-tool to use from the `.gpt` file. |
81 | 54 |
|
| 55 | +For a detailed description and more options, refer to the `gptscript --help` command. |
0 commit comments