paint-brush
What the Heck Is GPTScript?by@progrockrec
921 reads
921 reads

What the Heck Is GPTScript?

by Shawn GordonApril 18th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Acorn Labs is working on a tool to simplify Kubernetes containers. The tool is called GPTScript and is being developed for Rubra. This article will walk you through an introduction to the tool and examples. It will also give you some thoughts about where you could take it.
featured image - What the Heck Is GPTScript?
Shawn Gordon HackerNoon profile picture

Introduction

Late in 2023, I was considering writing an article about Acorn Labs' work simplifying Kubernetes containers. I even started it and wrote a few paragraphs, but then I got busy with other things. At the time, I was going to revisit it in February 2024, they made a couple of announcements; one was for Rubra, and the other was more of a personal project by one of the co-founders, Darren Shepherd, called GPTScript.


This project was so exciting that a month later, Acorn announced they were changing their company focus to GPTScript (not sure what would happen to Rubra).


I’ve been following all the developments on this project, closer than I typically do, because I find it absolutely amazing as enablement technology. It reminds me of the philosophy behind a product I worked with back in the 80s and 90s called MPEX from VESOFT, written by Eugen Volokh.


What Darren has done with GPTScript is kind of hard to wrap your head around at first, especially for a programmer. I haven’t spent enough time with it yet to fully understand all the implications, but I have a lot of thoughts about it.


In this article, I’ll walk through some basic introductions and examples and give you some thoughts about where you could take it.

Getting Started

I worked off the docs and various videos and examples; I gave this a go on my Windows 11 laptop. Let’s get this sucker installed:


winget install gptscript-ai.gptscript
$env:OPENAI_API_KEY = 'your-api-key'

The docs suggest running a “hello world” example at this point, but that isn’t very interesting, so let’s try the “bob” example. Also, note that there are many built-in examples you can get a list of by issuing the gptscript—-list-tools command and an online ‘examples’ directory.

terminal window of bob output


What does “bob.gpt” look like?


terminal window of bob script


This presents us with some obvious questions, like what this all means and how a value of ‘How are you doing?’ ended up in the ‘question’ argument. GPTScript operates around the notion of tools where a tool is described in a GPT file. Each file can be made up of more than one named tool, separated by three dashes.


Borrowing from the docs, 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):

GPTScript parameters

A tool starts with a preamble that defines the tool's name, description, args, available tools, and additional parameters. The preamble is followed by the tool's body, which contains the instructions for the tool. Comments in the preamble are lines starting with # and are ignored by the parser. Comments are not really encouraged as the text is typically more useful in the description, argument descriptions, or instructions.


I’m still not sure why Bob was giving a default value for the argument. It would change if I gave it an argument, so that was a bit of a mystery. I decided to try the samples-readme.gpt script, which looks like this:


samples-readme.gpt

Reading this, I understood that it would give me a summary of each gpt file in the examples directory. When I first tried it without an argument, it failed to find any input, so I tried with an example file as an argument, and it worked.


Then I tried it with their larger example script for hacker-news-headlines, and instead, it did what I thought it should have done the first time. It created a readme.md file in the examples directory with a summary of each example.


I’ve seen people in the community starting to generate some very cool tools that are being added to the GPTScript tools web page. I had a little bit of mixed results with my tests. Most things worked as expected, but I had a few things that didn’t, and I didn’t have the opportunity to dig deeper. That said, this is clearly powerful, and it is just scratching the surface.

Summary

As a lifelong programmer, this feels weird; it involves doing things in ways that seem like something is missing. This makes GPTScript fascinating and scary as if black magic is involved somehow. The natural language and loose feel of it take a little getting used to, but as you think about it, you start to realize how amazing this can be as an enablement technology.


One of the first things that came to mind, but I didn’t test, was could this be used to drive OpenFoam? OpenFoam is open-source CFD software that is rather notorious for how difficult it is to use, which is why I never learned how to use it. What if I could just describe what I wanted to do with it, and it worked? Imagine doing this with any software with an API you could talk to.


My mind starts to explode thinking about it. Acorn has created an online “tools” catalog that you can utilize, and they are iterating at an insane pace. This is really exciting.


Check out my other What the Heck is… articles at the links below: