SynkFlowAI is an advanced asynchronous framework written in Delphi that orchestrates AI thought chains in an elegant and efficient way. With a dynamic pipeline model, a configurable sequential scheduler, and the use of Promises, this framework meets the complex requirements of interacting with modern AI models like OpenAI.
This project is the logical continuation of the tutorial CerebraChainAI.
- Why This Framework?
- Installation
- Key Features
- Architecture Overview
- Project Structure
- Advanced Customization
- Limitations
- Contributions
- License
- Personal Conclusion
- Quick Links
In a world where artificial intelligence demands increasingly fine-tuned orchestration, SynkFlowAI
aims to prove that it's possible to merge research and development without compromise. This project was born out of a personal challenge, within an original context, to conceptualize a solution in my own way—a process that values rigor, innovation, and deep thinking over mere recognition.
"SynkFlowAI is not just a tool. It’s an architectural manifesto showing that structured, orchestrated, and parallel AI is possible—even in Delphi, in 2025."
- Smart Decomposition: Break down complex problems into logical sub-steps using Chain-of-Thought reasoning.
- Controlled Asynchrony: Handle asynchronous tasks using Promises for clean, fluid, and scalable code.
- Parallel Orchestration: Perform simultaneous web searches for fast and efficient data collection.
- Dynamic Pipeline: Organize your processing in a modular way to adapt to evolving environments.
This framework does not seek to compete with trendier languages, but to demonstrate that a modern, clear, and powerful architecture can emerge from a tool sometimes considered “traditional.” It’s like breathing new life into an old piano by composing a contemporary melody: showing that beauty and efficiency come from passion and thoughtful design—not just fashion.
- Clone the repository to your workstation in the directory of your choice as follows:
cd path\to\your\folder
git clone https://github.com/MaxiDonkey/SynkFlowAI
- Perform the same steps as in point 1 to install the DelphiGenAI repository, which enables the use of the OpenAI API wrapper.
cd path\to\your\OpenAIfolder
git clone https://github.com/MaxiDonkey/DelphiGenAI
- I used the VCL Windows Style - Windows 11 Mine Shaft 1.0 theme, available in the GetIt Package Manager.
4.Open the PromiseEx2.dpr
project with Delphi, then update the search paths in the project options as follows:
-
In the runtime directory, make sure to add the 32-bit DLL named
WebView2Loader.dll
, which you can find in the DLL folder of the repository. -
Modify the Openai key by yours :
const
OpenAIKey = 'My_OpenAI_key';
- Run the project. You should get the following:
-
Structured Asynchrony
Advanced asynchronous task management via Promises, enabling secure and fluid task chaining. -
Dynamic Pipeline
A flexible and evolving processing sequence, adaptable to many use cases. -
Chain-of-Thought (CoT)
An approach to model complex reasoning through steps, making problems easier to decompose and understand. -
Modular Architecture
Includes an IoC Container for dependency injection, ensuring modularity and easy testing. -
Native OpenAI Integration
Efficient streaming and parallel request handling to fully leverage modern AI model capabilities. -
Silent Mode + Streaming
Supports running chains silently (no UI) and receiving real-time streaming responses from the AI.
A 4-step orchestrated chain:
- Topic clarification / segmentation
- Parallel documentary research (AI)
- Data synthesis and structuring (JSON)
- Final writing (human-like, educational tone)
Key Modules:
- TPromise → asynchronous management with chaining
- TPipeline → groups processing steps
- TSampleChainExecutor → full execution scenario
- TOpenAIPromise / TOpenAIParallelPromise → AI API calls
- TPromiseAIFileManager → file naming + result saving
See also key diagrams in the glossary
TSampleChainExecutor.Create(
procedure(Params: TChainExecutorParams)
begin
Params.Client(IoC.Resolve<IGenAI>);
Params.Prompt('What is the impact of digital technology on education?');
Params.Path('Results');
end)
.Execute;
What the AI does:
- Clarifies the question.
- Generates sub-questions and performs AI-assisted parallel web research.
- Structures responses (JSON + text).
- Writes a final article, exported automatically.
- Automatically exports to .md and .data formats
This use case shows how a complete article can be generated automatically through 4 AI-driven steps (see full code in TSampleChainExecutor
).
Module / Unit | Main Role |
---|---|
ASync.Promise |
Core of the async engine (TPromise) |
ASync.Promise.Params |
Smooth parameter handling (Input, Model...) |
Async.Promise.Manager |
CoT data + models |
Async.Promise.Pipeline |
Groups steps into a pipeline |
OpenAI.Promise |
Sends requests to OpenAI (streaming) |
OpenAI.ParallelPromise |
AI-based parallel web search |
Sample.ChainExecutor |
Full scenario (4-step AI orchestration) |
OpenAI.FileManager |
Generates file names + handles saving |
For a deeper understanding of the architecture, see the diagrams in the glossary:
-
Global Diagram (UI + Logic + Services) – A starting point for understanding how all components interact globally.
-
Thought Chain Flow (Chain-of-Thought) – Helps you understand the multi-step reasoning process and how each stage contributes to the output.
-
Component Diagram (Core Services & Chain Execution) – A synthesized view of the relationships between services for easier grasp of the architecture.
-
All Diagrams – 6 diagrams available in the glossary.
-
IMarkDown: For the IMarkDown interface, the solution by Grahame Grieve was used. Learn more at delphi-markdown.
-
OpenAI API: The API wrapper for
OpenAI
, developed by me, is used in this project. See: DelphiGenAI. -
App Skin: The application uses the Windows 11 MineShaft skin.
-
Modify chain steps: redefine your own
TScheduleEvents
orTSampleChainExecutor
. -
Manage injections:
IoC.RegisterType<IDisplayer>('browser',
function: IDisplayer
begin
Result := TMyDisplayer.Create(MyVisualDisplayComponent, IoC.Resolve<IMarkDown>);
end,
TLifetime.Transient
);
- Create custom processing chains inspired by the
TSampleChainExecutor
example.
-
This project is a
proof of concept
. Although the provided example is based on VCL, it is entirely possible to develop an equivalent FMX version. To do so, simply implement theICancellation
andIDisplayer
interfaces and inject your new components accordingly. -
The project currently relies on the
DelphiGenAI
wrapper, but you're free to use other wrappers available on my GitHub. As of now, onlyDelphiGenAI
supports parallel request processing. However, other wrappers will be updated soon to include this feature. -
To integrate another wrapper (e.g., Gemini, Claude, Deepseek, or Mistral), refer to the structure of
OpenAI.Promise
,OpenAI.ParallelPromise
, andOpenAI.FileManager
, and adapt the dependency injection logic accordingly. -
PromiseDataTrash
(refer to unitASync.Promise.Params
) only removes instances when the application is closed. It would be advisable to implement a mechanism that cleans up expired instances during idle periods, for example.
Feedback and contributions are welcome! Feel free to submit ideas or open issues to help improve the project.
Distributed under the MIT License. Refer to the MIT LICENSE file for details.
This project represents a journey of research and experimentation. It combines rigor, innovation, and a personal approach to tackling technical challenges in a space often dominated by conventional paradigms. My goal isn’t to seek quick recognition, but to share a carefully documented proof of concept designed to inspire those who appreciate well-architected systems.
Thanks for your interest and feedback. Explore SynkFlowAI
and see how innovation can be born from the fusion of research and development.