Skip to content

Commit bb81288

Browse files
Update examples
1 parent a3decda commit bb81288

17 files changed

+80
-93
lines changed

examples/add-go-mod-dep.gpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tools: sys.read, sys.write, sys.exec
2+
3+
Edit the go.mod file and add ${package} version ${version} as a dependency in it

examples/count-lines-of-code.gpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tools: sys.find, count, add
2+
3+
Find all *.go files and count the lines of code in each file, add the result and print it
4+
5+
---
6+
name: count
7+
description: Count the lines of code
8+
args: file: The file to read and count
9+
10+
#!wc -l ${file}
11+
12+
---
13+
name: add
14+
description: Sum a bunch of numbers
15+
args: nums: A comma seperated list of numbers
16+
17+
#!python
18+
19+
import os
20+
import json
21+
22+
print(sum(json.loads("[" + os.environ.get("nums") + "]")))
Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
Tools: ls, count, summarize, compare
1+
Tools: sys.find, count, summarize, compare
22

3-
Find the top 10 go files that have to most lines of code. Then summarize each one and provide an overview of what this go program does. I don't want a file by file summary, just one overall summary.
3+
Find the top 10 go files that have to most lines of code. Then summarize each one.
4+
5+
Looking at the summary of all files write a short description of this program and it's function.
46

57
---
68
name: compare
@@ -13,14 +15,6 @@ for i in $(echo "${LIST}" | sed 's/[[,\]]/ /g'); do
1315
echo $i
1416
done | sort -n
1517

16-
---
17-
name: ls
18-
description: Recursively lists all go files
19-
20-
#!/bin/bash
21-
22-
find . -name '*.go'
23-
2418
---
2519
name: count
2620
description: Count the lines a file
@@ -32,18 +26,8 @@ wc -l "${FILE}"
3226

3327
---
3428
name: summarize
35-
tools: cat
29+
tools: sys.read
3630
description: Read a go file
3731
arg: file: The filename to read
3832

3933
First read the passed file and then summarize it's content into no more than 100 words
40-
41-
42-
---
43-
name: cat
44-
description: Read a files content
45-
arg: file: The filename to count the lines of
46-
47-
#!/bin/bash
48-
49-
cat "${FILE}" </dev/null

examples/echo.gpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# You can run this script with "gptscript echo.gpt --input 'Hello, World!'"
1+
description: Returns back the input of the script
2+
args: input: Any string
23
echo "${input}"

examples/edit.gpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tools: sys.read, sys.write
2+
3+
Edit the go.mod file and add k8s.io/api version v0.29.0 as a dependency

examples/fac.gpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tools: myfunction
22
What's the myfunction of 3
33

4-
---
4+
----
55
name: myfunction
66
tools: sub, mul
77
description: A function taking an integer as argument and returns an integer

examples/generate-gptscript.gpt

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/gh-cmd.gpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tools: gh-api
2+
3+
Print the names and review counts of the contributors who reviewed merged pull requests in the github.com/acorn-io/manager repo since 2024-02-01.
4+
5+
---
6+
name: gh-api
7+
8+
Description: A script to call the pr subcommand of gh cli tool. You cannot call this without any arguments.
9+
arg: args: The arguments to pass the to gh command.
10+
11+
#!gh ${args}

examples/git-commit.gpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tools: gitstatus, sys.abort
22

3-
Create well formed git commit message based of off the currently stated file
3+
Create well formed git commit message based of off the currently staged file
44
contents. The message should convey why something was changed and not what
55
changed. Use the well known format that has the prefix chore, fix, etc.
66

examples/hacker-news-headlines.gpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: starts a MongoDB database
1616

1717
#!/usr/bin/env bash
1818

19-
docker run -d -p 27017:27017 --name mongodb mongo:latest
19+
docker run --rm -d -p 27017:27017 --name mongodb mongo:latest
2020

2121
---
2222
name: mongo_command

0 commit comments

Comments
 (0)