Knowledge Base

Delphi and ChatGPT

No doubt you have heard about the new hype ChatGPT in the news. If not, ChatGPT is the new tool from OpenAI (Chat.OpenAI.com) that allows you to ‘talk’ to the OpenAI’s AI very quickly via a messaging interface. You can talk about everything, from ideas for an 8-year-old’s party, the workings of a quantum computer and programming languages like Delphi. And then it gets interesting.

ChatGPT can, in fact, program. Not like a real developer, but like an AI can program. That means there’s quite a limit to the code you can generate, but at the same time it can absolutely help you in development. It’s time for a short demo. I’ve written it out in this blog post, but if you’d rather watch than read it, you can find the accompanying video about ChatGPT and Delphi here. You will also see the process live, so it is definitely recommended to watch the video.

We start with a simple question; can you create a class in Delphi for managing a company?

 

The beauty of ChatGPT is that you can then continue with the same topic:

 

Besides quickly generating classes, it is also possible to set up API calls. As an example, let’s take the call to the OpenAI api itself:

As you can see, it is possible to use an AI for simple pieces of code to create basic Delphi code quickly. We can now go one step further and implement this in Delphi itself.

Unfortunately, ChatGPT does not have a public API available at the time of writing, but we can interact with normal OpenAI api. This still works a bit less advanced, but I expect the ChatGPT api to become available soon too. Anyway, I just quickly created a Delphi plugin that uses the OpenAI api and puts the code in Delphi.

 

As you can see, the generated code is not yet compilable. The ChatGPT currently gives significantly better results, and I can’t wait for the time when we can integrate it into the Delphi IDE. As soon as that time comes, I will provide the code for the Delphi plugin as well. For now, at least, you can get started with ChatGPT here. If you find any interesting results from your chats with ChatGPT, please let me know!

Contact

Let us help you to realise your ambitions

GDK Software UK

(+44) 20 3355 4470

GDK Software USA

+1 (575) 733-5744