ChatGPT provides a simple-to-use API that can add intelligence to virtually any application. To get started go to the OpenAI site and sign up for an account.
To use the API, you will need a key that you can find here. The key is a bearer token that you will pass in the header of the request.
That’s it! You are ready to start using the API. The screen shots below are using Ruly, but can be easily transcribed to Postman or your favorite coding platform.
Adding your own data to Chat GPT opens up a wealth of new possibilities. Although GPT has been trained by its creators on a wide variety of topics, it does not know everything, so it is possible to extend the platform using your own information to help solve your own unique business problems.
You can read more about how this is done at the OpenAI site:
Instead of uploading vast amounts of training data, a simpler approach to get started is by sending instructions to ChatGPT on how to answer questions.
Although this approach is possible using the interactive GPT interface by simply typing those instructions in, the API allows this process to be automated by sending these instructions in the background.
Let’s look at an example of how this would be accomplished using Ruly.
A common use case in software programs is the ability to parse data. For example, starting with a single Address field, extract the city name and store that in a separate City field.
675 Lincoln Ave, Chicago, Illinois 60093
The standard way to do this is to create what is called a regular expression. In this example, the regular expression will look for text between the first and second commas.
The no-code software developer still needs to be able to create regular expressions if they need to parse data. They can try finding the correct expression using Google or asking ChatGPT directly, so let’s see how we can automate the process by using a combination of:
The responses from GPT can be tailored to the context in which the question was asked.
Using Ruly an operation is created that combines these 2 elements. Note that when signing up for OpenAI, you will receive an authentication token that can be used in API requests.
The UserQuestion and InputString in the above operation are merge fields. When a user types in an input string and question and presses the OpenAI button, the entire request is sent to the OpenAI API endpoint.
Here is a simple user form that uses the operation created above to make calls to OpenAI. The user asks a question to parse the city name from an address field. The pattern created could be used in future requests to automate the parsing of City. It was created by asking OpenAI to not include an explanation.
The patterns that OpenAI created above work correctly. However, this is not always the case when tested with other questions and strings. It makes outright mistakes in many cases, or it selects a pattern that is not optimal for all use cases.
When told about the mistake then it will try again. It may take several attempts but it usually arrives at the correct answer.
Although OpenAI is able to generate regular expressions to solve complex problems, it can’t actually run and test the expression to make sure it works.
There is also the fundamental issue that it has not been trained to solve every possible problem.
When told about errors, the ChatGPT interactive user interface happily tries again. By providing this feedback, it is usually able to correct the error.
However unlike ChatGPT, the OpenAI API does not remember conversation history, so in an automated feedback loop, the entire conversation history needs to be sent with each request so that it can benefit from previous responses.
Read more about how to create a feedback loop using Ruly.
To make long-term improvements to OpenAI’s decision-making ability, training the model to improve responses using your own data is the way to go. We will discuss how this can be done in a future article.