Model enrichments
Introduction to model enrichments
Model enrichments are actions that automate parts of your manual workflows. An enrichment can jump-start the work on your application before you start with manual fine-tuning.
Use a dynamic model if you want your actions to be executed during every generation. See also Dynamic model.
The Software Factory comes with a number of ready-made enrichments. For more information, see Available enrichments.
In addition, you can build your own model enrichments. For example:
- A subroutine for an API connection that always contains a few standard parameters as well as a few extra that can be added manually.
- Base tables that always comply with a certain format.
- Prefilters that are often used in the entire system.
- Check if values and units are always on the same line; if not, correct that if needed..
- Formatting name and address details in a consistent way.
Types of model enrichments
Enrichments can be model-driven, data-driven, or AI-powered. Or a combination of these.
A model-driven enrichment will query the model and then create (potential) model updates. It can be used to check, for example, the consistency in your application. You can re-run it on a need-to basis.
A data-driven enrichment will prompt you for a runtime configuration when you start it. It queries the database to load the information required to present the model updates. Examples of this type of enrichment include generating missing indexes, creating mock data based on table content, and deriving control types and elements from data in the database.
An AI-powered enrichment will use the configured generative AI provider of the Software Factory to retrieve information from a large language model. Examples include generating descriptions, translations, comments, etc. See also Enable generative AI.
Available model enrichments
Model enrichments for the data model
Name | Description |
---|---|
Create a sample data model with AI | Swiftly generates a sample data model using AI. The provided application description will be used to create a diagram with tables, columns, and references. |
Suggest unique indexes when the data is unique | Reads all non-primary key columns of tables and suggests a unique index when the data is unique. |
Add a table description with AI | This enrichment inspects a table and generates a description based on important columns, for one or all tables. You can select which updates need to be executed. |
Generate descriptions for all tables with missing descriptions |
Model enrichments for the user interface
Name | Description |
---|---|
Translate all untranslated objects | Scans the untranslated items in your application and generates a translation based on existing translations for other languages. |
Create prefilters for checkboxes | Generates prefilters for columns that use a Checkbox domain control. |
Create prefilters for image combos | Generates prefilters for every column that uses an Image combo domain control. It also creates prefilter groups. |
Create prefilters based on domain elements | Generates prefilters for each element of a given domain. It also creates prefilter groups. |
Set up a drag-drop link | Sets up a drag-drop link between two tables by creating the background task, settings, and functionality structure. |
Set the display type to Hidden for drag-drop tasks | When drag-drop tasks are used in your application, there is no need for visible buttons in the user interface. This enrichment sets the display type for drag-drop tasks to hidden. |
Create a cube based on a table | Creates a cube based on a table. |
Model enrichments for functionality
Name | Description |
---|---|
Generate application logic based on natural language business rules | This enrichment is AI-powered. In its parameters, you can enter a natural language business rule that tells the enrichment when and where the rule should occur and what should happen. The enrichment will derive the logic concept and the model object and create a logic template. It can generate Default, Layout, Context, Trigger, and Handler logic. |
Fill the template description with a code summarization | Summarizes control procedure templates that do not yet have a description. Using AI, the summary will be generated based on the inspected code. |
Add comments to code | Adding comments to code is essential for understanding its functionality. This enrichment adds comments to a specific control procedure. It uses AI to understand your code and inserts comment lines where necessary. Comments will be added to control procedure code, template code, and dynamic model code, as needed. |
Template code review | This enrichment reviews the template code of a control procedure in review. Only the new or modified templates will be reviewed. When a template is assigned more than once, only one of those assignments will be used to review the code. Repeated review is possible. Existing OpenAI reviews will be removed, but resolved AI review comments may be reopened if the issue persists. Comments marked as 'won't-fix' will remain as such. |
Model enrichments for access control
Name | Description |
---|---|
Create a role based on a process flow and its steps | Creates a role with all required rights to grant an user access to the table variant specified in the enrichment run. |
Role creation based on a process flow | Creates a role with all required rights to grant an user access to the process flow specified in the enrichment run. |
Model enrichments for unit tests
Name | Description |
---|---|
Create mock data table from test database | Reads the contents of a given table and converts it into a mock data set that can be used for unit tests. |
Model enrichments for the transition to the Universal GUI
See Transition to the Universal GUI.
Model enrichments for the Upcycler
See Enrichments for the Upcycler.
Use a model enrichment
The Software Factory comes with a number of ready-made model enrichments.
In the execution overview of each model enrichment, you will find an instruction or explanation specific for that enrichment.
We will demonstrate how to use a model enrichment with an example. Create sample model data with AI is one of the available model enrichments. It swiftly generates a sample data model using AI. It uses the application description that you provide to create a diagram with tables, columns, and references.
menu Enrichment > Model enrichments > tab Enrich model > tab Select enrichment
-
Select the enrichment Create sample model data with AI.
Select an enrichment
-
Execute the task Create enrichment run . The focus changes to the tab Run enrichment.
-
Add a description of the data model that you want to create. Other enrichments require different input.
-
Execute the task Generate model updates .
-
Select the model updates that you want to execute from the list.
Select the model updates you want to execute
- Execute the task Execute model updates .
Once all the updates have been performed, the enrichment run is closed.
If any actions remain open, you will be prompted whether to close the run or to execute additional actions. To continue, you can select and execute all the actions that have not been completed yet. The enrichment run will end once all the actions have been executed or if you end it manually.
Re-run a model enrichment
menu Enrichment > Model enrichments > tab Enrich model > tab Select enrichment
You cannot rerun a closed enrichment run. To execute it again, Cancel it in the tab Select enrichment.
Create a model enrichment
Check the available model enrichments for inspiration and as examples.
Create a model-driven enrichment
You can create your own model enrichments.
The following steps apply to all the types of model enrichments:
menu Enrichment > Model enrichments > tab Maintenance > tab Enrichment > tab Form
-
Enter a title and instruction for your enrichment.
-
Select the Enrichment group from the drop-down list. See Create an enrichment group.
-
If necessary for your enrichment, add user input parameters in the tab Parameters. The values for these parameters must be provided when the enrichment is run. For example, if you create an enrichment that adds a new prefilter, you could include the prefilter name in a parameter. Parameters can have default values. A default query can even fill them. Parameters can be Mandatory and Multiline.
Add parameters to your enrichment
-
Add a template in the tab Templates. You can use model update parameters in the description of a template. That way, you can see which action is being carried out. For example, an enrichment that adds a prefilter to records if they are between a specific start date and end date could have the following description: 'Add prefilter for table @tab_id'.
Example template
This is an enrichment that adds a new prefilter:
-- Create prefilter
insert into tab_prefilter
(
model_id,
branch_id,
tab_id,
tab_prefilter_id,
type_of_prefilter,
insert_user,
insert_date_time,
update_user,
update_date_time
)
values
(
@model_id,
@branch_id,
@tab_id,
@tab_prefilter_id,
0,
dbo.tsf_user(),
sysdatetime(),
dbo.tsf_user(),
sysdatetime()
)
- Now, create a model update query in the tab Form > Model update. When you create a new one, an example query is added to the tab Model update.
Example model update query
-- Available variables
-- @model_id - Name of the current model
-- @branch_id - Name of the current branch
-- @enrichment_id - Name of the current enrichment
-- Additional user input variables will also be available
/*
insert into #model_update
(
model_update_id,
template_id,
default_active,
order_no,
parent_model_update_id
)
select
'@enrichment_id',
'@enrichment_id',
1,
10,
null
insert into #model_update_parmtr
(
model_update_id,
parmtr_id,
parmtr_value
)
select
'@enrichment_id',
'TAB',
tab_id
from tab
where model_id = @model_id
and branch_id = @branch_id
and tab_id = 'example'
*/
- Add the potentially executed updates to the table
#model_update
. - The table
#model_update_parmtr
contains the parameters that are used by the template. - The column
parent_model_update_id
can be used to set dependencies between model updates. If set, the model update can only be selected when the parent update is also selected. If theparent_model_update_id
is set but does not refer to an actual model update, the dependency will be ignored. - It is possible to use
is_truthy
to validate truthy input, such astrue
,yes
, and1
. A value is considered truthy when it is not literally true but is evaluated as true. If you are adding parameters to your enrichments that accept true or false values, use this function to validate the input. It will return 1 for truthy input or 0 otherwise. For example:set @no_yes = is_truthy(@parmtr_value)
You can also use the is_truthy
function in any other query running on the Software Factory database, such as the dynamic model and control procedure code.
Create a data-driven enrichment
A data-driven model enrichment follows the same steps as the model-driven enrichment. In addition, to make it a data-driven enrichment:
menu Enrichment > Model enrichments > tab Maintenance > tab Enrichment > tab Form
- Select the checkbox Data driven.
- The tab Database code contains a query field with instructions on how to set up the database query.
While constructing this query, you can use generic variables (
@model_id
,@branch_id
,@enrichment_id
) and any user variables specific to the enrichment.
With the database query, you can retrieve a temporary table with key-value pairs from the database.
The pairs can consist of raw values, such as table_id
as the key and a counter as the value,
or a JSON object as the key and a JSON object as the value for more complex use cases.
You can use the key-value pairs in the subsequent AI-powered step or the step that prepares the model updates. These steps are built with knowledge of the contents of the key-value structure.
Create a data-driven enrichment
Create an AI-powered enrichment
Make sure that you have enabled generative AI. See Enable generative AI.
An AI-powered enrichment follows the same steps as the model-driven enrichment. In addition, to make it an AI-powered enrichment:
menu Enrichment > Model enrichments > tab Maintenance > tab Enrichment > tab Form
- Select the checkbox AI-powered.
- The tab AI completion prompts contains a query field with instructions on how to set up the AI query.
While constructing this query, you can use generic variables (
@model_id
,@branch_id
,@enrichment_id
), in addition to the temporary key-value table retrieved from the database, if applicable.
You can use the AI query to set up a temporary table with key-prompt pairs. This query can access the model as well. The prompts will then be executed using the generative AI provider. The subsequent query that prepares the model updates can use the completions for each key retrieved from the generative AI provider.
Create an AI-powered enrichment
AI-powered model enrichment with prompt chaining
By default, an enrichment contains a single prompt or prompt set for the generative AI to complete. With prompt chaining enabled, you can introduce additional prompts or sets of prompts based on the result of earlier ones. This advanced prompting feature enables you to break down complex tasks into smaller, sequential steps.
Prompt chaining is integrated into the default model enrichments and can be applied to custom enrichments. To enable prompt chaining in your AI-powered enrichments:
menu Enrichment > Model enrichments > tab Maintenance > tab Enrichment > tab Form
- Select the checkbox Prompt chaining enabled.
- Specify the number of cycles. A cycle might end without a prompt, for example, if a step is skipped through an enrichment parameter. In such cases, the process will automatically move to the next cycle.
Prompt chaining enabled
When running an enrichment, the completion prompts query is executed for each cycle, providing access to the completions of all earlier cycles.
The temporary table #pc_data (key, completion)
is available to the completion prompts query and contains all previous completions.
To organize the prompt completion code for different cycles, use the variable @pc_cycle
, which indicates the current prompt chaining cycle, starting at 1.
The model update query has access to the completions of all prompt chain cycles. To avoid errors, the keys for each prompt must be unique in all prompt chain cycles within a run.
Example: AI-powered model enrichment with prompt chaining
The following example of an AI enrichment generates a snake-case system message ID based on a message translation, which is challenging to derive directly from the message translation. The solution involves a two-step process using prompt chaining: The first cycle uses AI to summarize the user input into a few words. In the second cycle, the AI converts the summary into the final message ID.
Example of an AI-powered enrichment
This enrichment generates a snake-case system message ID based on a message translation.
if @pc_cycle = 1
begin
-- Summarize the user input to a few words
insert into #ai_data (key, prompt)
values ('prep_summarize', concat('Summarize the text to 1-3 words: ', @input))
end
if @pc_cycle = 2
begin
-- Turn the summarized words into a snake_case variable
insert into #ai_data (key, prompt)
select 'message_id', concat('Provide a snake_case property name: ', completion)
from #pc_data
where key = 'prep_summarize'
end
Create an enrichment group
Enrichments can be grouped together to display them logically.
To create an enrichment group:
menu Enrichment > Model enrichments > tab Maintenance > tab Enrichment groups
- Enter a name for the Enrichment group.
- Select the Sequence no. With this setting you can influence the order in which the enrichment group appears.
The enrichment group is now available for selection if you create or edit an enrichment.