Blog

All Blog Posts  |  Next Post  |  Previous Post

AI based scheduling in classic Delphi desktop apps

Monday, August 4, 2025

TMS Software Delphi  Components
In the evolving landscape of software development, the fusion of classic Delphi desktop applications with cutting-edge AI capabilities is no longer a futuristic dream—it's a reality. Thanks to TMS AI Studio, developers can now harness the incredible power of Large Language Models (LLMs) like OpenAI, Claude, Gemini, Grok, Mistral, Ollama and DeepSeek directly in their VCL or FMX apps.

Today, we're excited to showcase a real-world Delphi application that does something remarkably useful: it automatically schedules car repair tasks in a workshop, leveraging LLM function calling, prompt engineering, and real-time file-based context injection. This isn't just an upgrade—it's a leap forward in how we approach automation and intelligent assistance in desktop software.

TMS Software Delphi  Components


The Power Behind the App: Delphi + LLM + TMS AI Studio

This application uses the TTMSMCPCloudAI component from the TMS AI Studio suite to interact seamlessly with a variety of LLM providers. It enables:

  • Dynamic selection of the AI service (OpenAI, Claude, Gemini, etc.)

  • Injection of a custom car maintenance knowledge file (carmaintenance.txt)

  • Setting up function calls such as AddSchedule, GetCurrentTime, and GetOccupiedListto be called automatically from the LLM

  • Ask the LLM for intelligent task scheduling that respects existing calendar constraints

  • Our visual TMS FNC Planner  component showing booked and available time slots


Here's a quick glance at what happens when the user clicks the "Execute" button:

TMSFNCCloudAI1.AddFile('.\carmaintenance.txt', aiftText); // send general car maintenance information
TMSFNCCloudAI1.Context.Text := Memo1.Lines.Text; // send the prompt TMSFNCCloudAI1.Execute('proc');

With this simple code, the LLM receives a prompt along with real-world context in the form of a domain-specific file. The file carmaintenance.txt is a text file the contains typical repairs to be executed at a car repair shop and the approximate time needed for these repairs. (For this example, the overview of typical car maintenance actions and time required was actually also obtained from Grok AI).  Now the AI doesn't guess—it knows.


What LLMs Bring to the Table

The integration with TMS AI Studio enables LLM function calling, meaning the AI can intelligently decide when to call a Delphi procedure (like adding a schedule) and with what parameters. This is defined clearly via TTMSMCPCloudAI in the Delphi app using tools like:

tool := TMSMCPCloudAI1.Tools.Add;
tool.Name := 'AddSchedule'; tool.Parameters.Add.Name := 'StartTime'; // first parameter sets the start time tool.Parameters.Add.Name := 'EndTime'; // second parameter sets the end time tool.Parameters.Add.Name := 'Task'; // third parameter sets the car maintenance task tool.Parameters.Add.Name := 'Customer'; // fourth parameter sets the customer name for who to maintain the car tool.OnExecute := DoHandleAddSchedule; // event handler to call when the LLM decides to call this function

Here we have defined the AddSchedule function to allow the LLM to add an item to our visual TMS FNC Planner. When the LLM decides to call this function, the event OnExecute for this tool will be triggered and this is the place where we add the Delphi code to actually interact with the Planner component and add an item. The code is as following:

procedure TForm1.DoHandleAddSchedule(Sender: TObject; Args: TJSONObject; var Result: string); var dt1s, dt2s,descr,customer: string; dt1,dt2: TDateTime; plit: TTMSFNCPlannerItem; begin if Assigned(Args) then begin // extract the parameters from the JSON object dt1s := Args.GetValue<string>('StartTime'); dt2s := Args.GetValue<string>('EndTime'); descr := Args.GetValue<string>('Task'); customer := ''; if Assigned(Args.Find('Customer')) then // since not set as required parameter, check if it is there customer := Args.GetValue<string>('Customer'); dt1 := ISO8601ToDate(dt1s, True); // dates are requested in typical JSON ISO 8601 date/time format dt2 := ISO8601ToDate(dt2s, True); plit := TMSFNCPlanner1.Items.Add; // create a new TMS FNC Planner item plit.StartTime := dt1; plit.EndTime := dt2; plit.Title := descr; plit.Text := customer; end; end;

In a similar way, we have setup function calling to get the actual time, so the LLM know what is our current time where maintenances can be scheduled as well as to get a list of already occupied times in the Planner.

This is the tool setup for it:

tool := TMSMCPCloudAI1.Tools.Add; tool.Name := 'GetOccupiedList'; tool.Description := 'Get an array of the timeslots that are occupied this week'; tool.OnExecute := DoHandleOccupiedList;

And this is the handler. It loops through all items in the TMS FNC Planner and returns an array of start and end times of existing scheduled items in the Planner:

procedure TForm1.DoHandleOccupiedList(Sender: TObject; Args: TJSONObject; var Result: string); var i: integer; plit: TTMSFNCPlannerItem; res: string; begin res := '['; for i := 0 to TMSFNCPlanner1.Items.Count - 1 do begin plit := TMSFNCPlanner1.Items[i]; if i > 0 then res := res + ','; res := res + '{"StartTime":"'+ GetISO8601DateTime(plit.StartTime)+'","EndTime":"'+GetISO8601DateTime(plit.EndTime)+'"}'; end; res := res + ']'; Result := res; end;

From Natural Language to Concrete Schedule

Imagine a user types:

"Book an oil change for Mr. Smith on Tuesday morning."

The app:

  1. Sends this to the LLM along with the existing schedule and maintenance guide.

  2. The LLM parses the request, checks for conflicts using GetOccupiedList, and finally calls AddSchedule.

  3. Delphi handles this via the DoHandleAddSchedule event and updates the calendar UI.

This is where classic meets futuristic. The app feels like a smart assistant, not a rigid form-based tool.


Why This Matters

Delphi developers can now:

  • Extend existing apps with AI-assisted logic

  • Build intelligent tools without rewriting in Python or JavaScript

  • Use local or cloud-hosted LLMs depending on need and privacy

And thanks to TMS AI Studio, this is done using drag-drop components and well-known Delphi patterns—no need to leave your comfort zone.


The Journey Continues: Tuning, Testing & Experimenting

No two LLMs are alike. Some handle temporal logic better, others prefer verbose instruction. This means:

  • You experiment with different LLM providers

  • You refine your prompts over time

  • You observe what works best for your users and domain

TMS AI Studio makes this easy. Just change the combo box and you're switching providers on the fly!  Your application logic remains 100% the same, regardless of LLM you want to integrate with:

case combobox1.itemIndex of
0: TMSMCPCloudAI1.Service := aiOpenAi; 1: TMSMCPCloudAI1.Service := aiClaude; 2: TMSMCPCloudAI1.Service := aiGemini; ... end;

Demo app

You can download the fulll code of this demo app here. Request the API keys for the LLMs you want to experiment with. For this application, we have also used the TMS FNC Planner, so, make sure you have other than TMS AI Studio, also TMS FNC UI Pack installed. The demo app is created with the FireMonkey framework and thus is cross-platform. But you can as well use all these components in an existing Windows 32bit or 64bit VCL application.
It is interesting to see how different LLMs handle the scheduling in a different way. Surely, with a more precise prompt, things can be streamlined. But with the default prompt, it is remarkable that Claude for example will add 30min extra time with each scheduled maintenance as a sort of safety. OpenAI was quite reliable and consistent. Gemini on the other side often decides to ignore the working hours or lunch, mainly because it tends to use the maintenance task worst case time, whereas OpenAI and Claude tend to take the best possible time. All in all, these are very interesting experiments that surface particularities of the different LLMs and their models! 


Conclusion

With TMS AI Studio, the age of intelligent Delphi apps is here. You can now build applications that feel responsive, context-aware, and almost human in their interactions—all within the familiar and powerful world of native Delphi development.

TMS Software Delphi  Components

Whether you're scheduling car repairs, managing bookings, or building custom tools for logistics, TMS AI Studio + LLMs will give your app superpowers.



Bruno Fierens




This blog post has received 2 comments.


1. Tuesday, August 5, 2025 at 4:27:05 PM

A good task for AI would be the traveling salesman problem. For example, there are 30 customers and 6 employees. Each employee can handle 5 customers on a single tour. I have the customers'' addresses. Can the AI compile the optimal routes?

info


2. Tuesday, August 5, 2025 at 4:49:30 PM

A good experiment indeed. We''ll keep it in mind for a next demo.

Bruno Fierens




Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post