How to create your own GPT.

With AI set to become a more integral part of our daily lives, through technologies such as chatbots, AI assistants, and intelligent hardware. I felt like it could be beneficial to start refreshing my understanding on how to build with AI as a Software Engineer. Today I will experiment with the GPTs store recently announced and create a custom GPT. Please note that this feature is currently available only for premium subscribers.

Building a custom GPT can be accomplished in two primary ways: through a chat interface or via the configuration screen. The chat interface acts as a GPT designed to assist in creating other GPTs. By simply instructing the GPT creator with a command like “Create a GPT focused on travel advice,” it will prompt you with questions to specify the title, logo, and even generate a functional prompt for your custom GPT. On the other hand, the configuration screen offers a more hands-on approach, allowing for manual input of all the necessary details to tailor your GPT.

This image has an empty alt attribute; its file name is i1-960x1024.png

Until now, our customizations have been limited to utilizing the pre-existing knowledge within OpenAI’s models. However, it is also possible to extend the model’s functionality by enabling it to access and incorporate external, task-specific information, or to take actions outside of GhatGPT. This could include, for instance, fetching real-time stock market data, providing weather updates, or interacting with Alexa devices to play songs or turn on the lights. This can be achieved by actions. Actions are defined using the OpenAPI specification, which is a syntax to define the look and feel of your API. The interesting part about actions is that all you need to do is to define the schema and the model comprehends it and utilizes it accordingly when responding to queries or performing tasks. With a well defined schema, GPT can integrate with external data sources and services, significantly enhancing its utility and application scope.

We can enhance our travel GPT utility by integrating actions that leverage real time data. As a traveler, I find useful discoveryng nearby places that are highly recommended and have good ratings. However, GPT lacks access to the most recent reviews or ratings from sources like Google Maps or Trip Advisor, so lets create an action to access this information.

The action findInteresting is a GET that takes latitude longitude and a place type. The supported type places are bar, landmark, museum, tourist_attraction and art_gallery. This action allows GPT to find places of the selected type close to the users location. Please note that GPT does not currently support sending the users location, so this would have to be part of the users prompt either by giving the coordinates or by giving the name of the city or a location reference. Our service would be in charge of retrieving places that are well ranked, have positive comments and send those places back to the custom GPT. We can implement this using any language or framework. I used Typescript, NodeJs and Serverless hosted in AWS but the implementation details are topic for another day.

This image has an empty alt attribute; its file name is i3-1024x929.png

To define the response schema we can create OpenAPI objects for Place, Review and PlaceType. The place object contains the average user rating, the place type and the user’s reviews. The review contains the the text of the review and the user rating. Objects are simple yet powerful to convey as much information as possible with the least amount of fields. On the back, the API talks to service providers like Google Maps or Trip Advisor to get real time information. Simple, right? Now testing the full integration:

This image has an empty alt attribute; its file name is i4-1024x960.png

And it works! With the prompt Please recommend museums to visit new near el Angel de la Independencia in Mexico City GPT is able to find the coordinates to call our defined action. Then the API returns a few places of type museum with high ratings and a bunch of user reviews as well. Feel free to use this custom GPT and to create yours too!

Posted in Uncategorized | Leave a comment