The new SmartCore AI Components Pack, available in GetIt for RAD Studio 13, introduce a new set of core AI components to Delphi and C++Builder.
Developers can integrate these AI components into both existing and new applications, addressing many popular AI use cases, such as providing support for in-product content creation like generating images and other media, adding in-product localization support for on-the-fly translation, delivering in-app smart insights and personalized recommendations for data analysis, or building an in-app chatbot to add interactivity to an existing application.
This is a modular component suite to simplify calling AI providers (OpenAI, Claude, Gemini, and Ollama are included) from Delphi and C++Builder applications.
Table of Contents
Overview
The SmartCore AI Components feature is a building block and a foundation for the future. It’s a foundational architecture that our customers and third-party vendors can build on and extend to integrate with additional AI engines and UI controls.
The SmartCore AI package includes:
- A new AI connection component, with a role similar to that of a database connection in FireDAC. This is an AI-engine agnostic component which uses specific drivers to communicate via REST with different AI engines, including OpenAI, Claude, Gemini, and Ollama. The SmartCore AI engine provides the ability to add additional drivers, enabling AI providers to expand the capabilities of your project as the market evolves. The configuration is managed via an easy-to-use AI connection wizard.
A set of AI request components for different data types, such as text, images, and structured data, which can be associated with prompts. The components can be bound directly with UI controls to display the results of the AI interaction. - With the SmartCore AI Components Pack, users can integrate AI into both existing and new applications. The SmartCore AI components enable you to support many popular AI use cases, such as providing support for in-product content creation like generating images and other media, adding in-product localization support for on-the-fly translation, delivering in-app smart insights and personalized recommendations for data analysis, or building an in-app chatbot to add interactivity to an existing application.
Notice that drivers can be extended by overriding virtual methods or creating new driver components. As mentioned, this is an open architecture, built to be enhanced by our customers, community members, and third-party components vendors to help keep pace with the ecosystem of rapidly evolving AI technologies.
Installation and Getting Started
Download the SmartCore AI Component Pack from GetIt to start using the AI connection component.
The following is a list of the components installed by the Smart AI Components pack:
A set of associated demos is going to be shortly available in the RAD Studio 13.0 Demo repository. Specifically, you can find the SmartCore AI Components demos at github.com/Embarcadero/RADStudio13Demos/tree/main/Object%20Pascal/SmartCoreAI. These are not part of the current 13.0 demos installation, but if you have installed the demos with the product, you can get an update them directly via git from within their installation folder in the normal way.
Once the package is installed, follow these steps to get started:
- Drop a
TAIConnection
, assign a driver, and assign one or more request components. - Use the Connection Wizard to edit and test the parameters (double click on
TAIConnection
). - Or manually configure params: API key, model, BaseURL, etc.
- At this point, you can start using any of the other components.
You can find more information in DocWiki at https://docwiki.embarcadero.com/RADStudio/en/SmartCore_AI_Component_Pack. The DocWiki page also includes a list of the demos and their scope. The remainder of this blog post will guide you step by step in building a first demo.
Visual Step-by-Step Guide To Build your First SmartCore AI Demo
- Let’s start by creating a new Delphi VCL Application (but a C++ one or a FireMonkey one are also possible).
- Next, add an AI Connection component to it
- Open the AI Connection Editor:
- By selecting a driver in the combo box on top, the AI connection Editor and it will populate the parameters:
- Add you own API key in the field. You need to have one provided the LLM vendor you want to use, excluding Ollama.
- After you add the BaseURL (prepopulated) and the API key, you can go to the Model field and use the available drop down to select one of the available models, depending on the provider.
- Click the “Test Connection” button to verify the configuration is correct.
- Press OK to close the AI Connection Editor. The component editor will automatically add a driver component to the designer, matching the selected AI driver.
- Now create the UI. It could be as simple as dropping to the form a Memo control and a button.
- Now you can drop an
AIChatRequest
component and associate it with the connection. - In the button event handler, invoke the text request, like this:
- Once the response is ready, an event is triggered. There are many different events you can handle in the
AIChatRequest
component, but the simplest approach is to handle theOnResponse
event, with an event handler like so:
- That’s all you need for a working client sending a text request to an LLM!
- Next, you might want to handle graphic requests. In this case the code is a little more complex. First, drop an
AIImageRequest
component on the designer. Add an Image control and another button. Your form in the designer will look more or less like this (in this case, I also added a PageControl with two pages, for image and chat): - To query an LLM for an image, in the request code you have to configure the request object in code, depending on the LLM provider before executing the request. You can use something like this:
- Similarly, an event is triggered upon completion, and you can read the image from a stream and load it in an Image control (in this case, it’s a VCL application, but FireMonkey is similar):
- Here’s the result of asking for “Leonardo Da Vinci carrying a Delphi box in Florence” not a good picture — but I got this after many worse attempts!
(Image generated by dall-e-3)
The SmartCore AI Components Makes Adding Powerful AI To Your Applications Easy
This is just the beginning of our journey to help you build AI applications with RAD Studio. The components are much more powerful than this blog post shows, and the demos we are shipping can get you help started with the capabilities of SmartCore AI. Beside text and images, the demos also demonstrate a third, very useful category of AI response you can achieve: JSON structured data.
Stay tuned for more blog post and webinars showing more of SmartCore AI Components Pack. But don’t wait – you can start experimenting today.