English as a programming language is (almost) here

Last week Darren Shepherd, CTO at Acorn, announced on Twitter his last crazy OSS project: GPTscript.

I paid attention because I always say that, if you want to know what people will be doing 3 years from now, you have to watch what Darren, Shannon and Sheng are building today. They have an industry track record for this.

When I saw the tweet I skimmed through the README and this was my first reaction:

Over the weekend I sat down to figure out where I could fit half day of experiments to play with it and figure out what this crew was up to and, since I had half an hour to spare, I started to look around. What you will read in the remaining of this post was the course of the events in 30-ish minutes (not half a day).

The more I was looking into the examples in the README file, the more I was convinced that this was "Langchain, but in English instead of Python".

I have always been intimidated by Langchain to be fair. It seems to be very powerful but also overwhelming and the bar of entry isn't really at "English is the new programming language". You've got to know Python (or TypeScript). I have then come across Griptape which I have always described as "a Langchain that I can understand and relate to more easily".

Back to GPTscript, not being someone with a lot of imagination for use cases I thought: "if GPTscript is a Langchain (or a Griptape) that uses English instead Python, I should be able to implement one of their tutorials in English". While I've always got lost in Langchain tutorials, I found the Griptape's learning courses to be top-notch and very effective for people that want to learn the tech (highly recommended).

Luckily, last year I went through the Compare Movies using Griptape Workflows tutorial, and it was great. The idea of this tutorial is to demonstrate how, given as an input a set of short movies descriptions, an LLM would be able to figure their titles, source a complete summary for each and compare the movies based on their summaries. To date, you can see the diagram of this workflow at this link.

Because I am slow, and I am not a great developer, it took me a few hours to go through it and that involved a lot of copying and pasting of Python code into my IDE. If you look at the entire tutorial you will see that the "English" component of the program is limited to a few prompts. Roughly 95% of the program is a regular Python application that builds the workflow I have described above. Griptape has introduced specific Python libraries and classes to implement these concepts (e.g. Pipelines, Workflows, Tasks, etc).

I set myself up for a challenge to figure how I could create a GPTscript program that did the same thing. But in English (!).

Inspired by the examples in the GPTscript README I started to edit (no copy and paste) a file called moviescomparison.gpt with this content:

[ click on ... to see the entire script]

 1tools: getmoviename, getmoviesummary, comparemovies
 2
 3I will provide you a list of movies to compare. You should first find the title of the movies from a small description. You would then generate a summary for each. Ultimately you make a comparison of those movies based on their summaries. This is the list: 
 4
 5- boy finds alien in backyard
 6- a shark attacks a beach
 7
 8---
 9name: getmoviename
10description: I find movie titles out of a description.
11args: description: The description of the movie I need to find the title of.
12
13Find the title of the movie based on this description: ${description}
14
15---
16name: getmoviesummary
17description: I provide a movie summary based on a movie title.
18args: title: The title of the movie I need to provide a summary for.
19
20Provide a summary for the following movie: ${title}
21
22---
23name: comparemovies
24description: I compare movies based on their summaries.
25args: moviesummaries: A list of movies summaries.
26
27Provide a comparison of the following movies: ${moviesummaries}

What happened next was a bit terrifying (in a good way). Here is why:

  • First and foremost, this script worked at first attempt. Honestly, this has never happened to me when writing a program. Certainly, it has never happened when writing a program from scratch. If you think about this it makes sense because, other than a few general formatting rules, English is a much more forgiving programming language when it comes to syntax errors and ways to express a thought compared to the strict rules of a traditional programming language. For example, I am sure that instead of Find the title of the movie based on this description: ${description} I could have used Figure out the movie title off of this description: ${description} (and likely injecting syntax errors that an LLM would interpret and normalize).
  • As I started to craft the comparemovies function I started to wonder how I could signal that the args moviesummaries was an array of movies. After a bit of thinking my reaction was "screw it, if this is English for real, it will figure it out from the logic of the flow and the intrinsic requirements to achieve that goal of comparing them". And it just did it. The output was comparing the two movies I hinted (E.T. the Extra-Terrestrial and Jaws).

This was the output of the program above:

 1OUTPUT:
 2
 3E.T. the Extra-Terrestrial:
 4- Genre: Science Fiction, Family
 5- Plot: A young boy, Elliott, befriends a stranded extraterrestrial, E.T., and with his siblings, attempts to help E.T. return home while avoiding government agents.
 6- Themes: Friendship, adventure, the innocence of childhood.
 7
 8Jaws:
 9- Genre: Thriller
10- Plot: A great white shark terrorizes a small island community, leading the local sheriff, a marine biologist, and a shark hunter to team up to stop it.
11- Themes: Fear, survival, man vs. nature.

Note that the output I am getting above is slightly different from the output described in the Griptape tutorial likely due to some different prompting approaches I am using in the comparison. In 20 minutes I did not have enough time to go check all the details but that is not the point I want to make in this short blog.

Super curious to see how Darren and Co. evolve this project. This is definitely a super intriguing way to build generative AI applications.

By the way, as I was exploring GPTscript, it occurred to me to realize that this approach is not novel (conceptually). This is the same "using generative AI to build generative AI applications" approach that AWS took with PartyRock.

For example, you could use the following "program" (or "prompt") in PartyRock to build a very similar workflow:

1Build an application that takes as an input a list of short movie descriptions and as an output the following: 
2- the list of movies titles found based on those descriptions (only one title per description)
3- a list of movie summaries based on the titles
4- a comparison of the movies based on their summaries

This would be the result when the input is populated with the same movies descriptions used above:

It is interesting to note how the outputs differ with somewhat similar prompts depending, likely, by the LLM being used. This is an area that I would like to explore more in future posts and that intrigues me in a big way.

The difference between the two approaches, as I see it, is that PartyRock is an "application to build applications" whereas GPTscript is more like a lower level "English-based programming language to build applications".

Regardless of these nuances (easier to start with PartyRock but likely more flexibility to be achieved with GPTscript), in my opinion, the key for all these mechanisms is how open and extensible they are to the world outside the LLM. This movie example program is fairly self-contained in the sense that all these steps happen by only talking to the LLMs. GPTscript already supports some basic "tools" to search the web, read and write files, etc. but this is just the basic. Imagine a world where you could build these class of applications that talk to all systems out there and use LLMs as a glue. This is an area where LangChain (and GripTape to some extent) has an edge over what you can do with GPTscript today.

This does look like the future. Interesting times to be alive, for sure.