What's new in GPTScript v0.4

Apr 5, 2024 by Craig Jellick
What's new in GPTScript v0.4

Hot on the heels of the v0.3 release, we're pleased to bring you GPTScript v0.4. This release brings support for creating OpenAPI backed tools.

For those unfamiliar, OpenAPI is a popular specification for describing HTTP-based APIs. For a bit more detail and color, here's the description from the spec's website:

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.

This standard makes generating clients to consume conformant APIs quick and easy. Generating such clients and calling APIs is nothing new, but what's exciting about GPTScript's integration is just how easy it is. To use an OpenAPI compliant API from a GPTScript, all you have to do is reference the schemas as a tool. OAS's canonical example is an API for a pet store, so we'll use that as an example:

Tools: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml List all the pets. After you get a response, create a new pet named Mark. He is a lizard.

That's it! GPTScript parses the schema, maps the API operations to tools, and supplies them to the LLM to accomplish the task at hand.

We've also made it easy to discover just what tools (API operations) are available from a particular schema with the --list-tools call. Here's what it looks like for our pet store example:

$ gptscript --list-tools https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml Name: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml Description: This is a tool set for the Swagger Petstore OpenAPI spec Export: createPets, listPets, showPetById Model: gpt-4-turbo-preview --- Name: createPets Description: Create a pet Model: gpt-4-turbo-preview Args: requestBodyContent: --- Name: listPets Description: List all pets Model: gpt-4-turbo-preview Args: limit: How many items to return at one time (max 100) --- Name: showPetById Description: Info for a specific pet Model: gpt-4-turbo-preview Args: petId: The id of the pet to retrieve

If you want to limit the API operations you make available to the LLM, you can use the from syntax. For example, if I only want my script to be able to view pets and not create them, I'd reference the API like this:

Tools: listPets, showPetById from https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml

Things to keep in mind

There are a few caveats with this feature. The firs is that we currently just support version 3 of the OpenAPI spec. We may add version 2 support based on demand. Second, GPTScript provides some flexibility in resolving the server in your API endpoints. Third, there are some nuances on how to handle authentication. Finally, not all MIME Types are supported. For details on all of these, please check out the docs.

Wrapping Up

That's it for this overview of the v0.4 release and the OpenAPI-backed tools feature. Feel free to check out the release notes for more details and join us on Discord if you have any questions or feedback.