You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/appstore/use-content/platform-supported-content/modules/genai/prompt-management.md
+24-25Lines changed: 24 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,14 @@ description: "Describes the Prompt Management functionality that assists develop
9
9
## Introduction
10
10
11
11
Prompt management allows users to develop, test, and optimize their GenAI use cases by creating effective prompts to interact with large language models (LLM).
12
-
Using the Conversational UI module (available as part of [GenAI for Mendix](https://marketplace.mendix.com/link/component/227931)), you can use the prompt management interface in your app to define prompts at runtime and manage multiple versions over the course of time. It also supports defining variables that serve as placeholders for data from the app session context which are replaced by actual values when the end user interacts with the app. The module contains the necessary data model, pages, and snippets to include a prompt management interface to your app and get started.
12
+
Using the Conversational UI module (available as part of [GenAI for Mendix](https://marketplace.mendix.com/link/component/227931)), you can use the prompt management interface in your app to define prompts at runtime and manage multiple versions over time. It also supports defining variables that serve as placeholders for data from the app session context which are replaced by actual values when the end user interacts with the app. The module contains the necessary data model, pages, and snippets to include a prompt management interface to your app and get started.
13
13
14
14
### Typical Use Cases
15
15
16
16
Typical use cases for prompt management include the following:
17
17
18
-
* The app includes one or more chat completions interactions with an LLM.
19
-
* The prompts for the LLM interaction need to be updated or improved without changing the code of the LLM interaction. This enables people outside of the development team to change prompts (for example, data scientists).
18
+
* The app includes one or more chat completion interactions with an LLM.
19
+
* The prompts for the LLM interaction need to be updated or improved without changing the code of the LLM interaction. This enables people outside the development team to change prompts (for example, data scientists).
20
20
* The use case benefits from rapid iterations on prompts, models, and variable placeholders in a playground set-up, separately from app logic.
21
21
22
22
### Features
@@ -60,58 +60,58 @@ The module includes a set of reusable pages, layouts, and snippets, allowing you
60
60
#### Pages and Layouts {#pages-and-layouts}
61
61
62
62
You need to include the **Prompt_Overview** page so that prompt admin users can access it. For example, you can add it to your navigation, home page, or dedicated tools/settings page.
63
-
If you need to change the layout or apply other customizations, Mendix recommends copying the page to your own module and modifying it to match your app styling or use case. the**Snippet_Prompt_Overview** snippet includes the content of the same page.
63
+
If you need to change the layout or apply other customizations, Mendix recommends copying the page to your own module and modifying it to match your app styling or use case. The**Snippet_Prompt_Overview** snippet includes the content of the same page.
64
64
From this overview, the user can reach the **Version_Details** page to edit the prompt and execute tests. If customization is needed, its contents can be found in **Snippet_Prompt_Details**.
65
65
66
-
For an example, download and run the [GenAI Showcase App](https://marketplace.mendix.com/link/component/220475) to see the pages in action.
66
+
For example, download and run the [GenAI Showcase App](https://marketplace.mendix.com/link/component/220475) to see the pages in action.
67
67
68
-
### Configure Deployed models {#deployed-models}
68
+
### Configure Deployed Models {#deployed-models}
69
69
70
70
You need at least one GenAI connector that follows the principles of GenAI commons to interact with LLMs from the Prompt Management logic. To test a prompt, you must configure at least one Deployed Model for your chosen connector. Refer to the specific connector’s documentation for detailed setup instructions on configuring the Deployed Model.
71
71
72
72
* For [Mendix Cloud GenAI](https://marketplace.mendix.com/link/component/227931), included by default, importing the **Key** from the Mendix portal automatically creates a MxCloud Deployed Model. This is part of the [configuration](/appstore/modules/genai/MxGenAI/#configuration).
73
73
* For [Amazon Bedrock](https://marketplace.mendix.com/link/component/215042), the creation of Bedrock Deployed Models is part of the [model synchronization mechanism](/appstore/modules/aws/amazon-bedrock/#sync-models).
74
-
* For [OpenAI](https://marketplace.mendix.com/link/component/220472), the configuration of OpenAI Deployed Models is part of the [configuration](/appstore/modules/genai/openai/#general-configuration)
74
+
* For [OpenAI](https://marketplace.mendix.com/link/component/220472), the configuration of OpenAI Deployed Models is part of the [configuration](/appstore/modules/genai/openai/#general-configuration).
75
75
76
-
### Write the prompt {#write-prompt}
76
+
### Write the Prompt {#write-prompt}
77
77
78
-
When the app is running, a user with the `PromptAdmin` role can set up a prompt and test it with a deployed model. The user can decide to create either a Conversational prompt, intended for scenarios where the enduser interacts through a chat interface, or a Single-Call prompt, designed for isolated text generation purposes. While writing the system prompt (and for Single-Call prompt also the user prompt) the prompt engineer can include variables by enclosing them in double braces, `{{variable}}`. The actual values of these placeholders are typically known at runtime based on the user's page context.
78
+
When the app is running, a user with the `PromptAdmin` role can set up a prompt and test it with a deployed model. The user can create either a Conversational prompt, intended for scenarios where the end-user interacts through a chat interface, or a Single-Call prompt, designed for isolated text generation purposes. While writing the system prompt (for both conversational and single-call types) or the user prompt (only for the single-call type), the prompt engineer can include variables by enclosing them in double braces, for example, `{{variable}}`. The actual values of these placeholders are typically known at runtime based on the user's page context.
79
79
80
-
#### Test and refine prompt
80
+
#### Test and Refine the Prompt
81
81
82
-
To test the behavior of the prompts, a test can be executed. The prompt engineer must provide test values for all variables defined in the prompts. Additionally, multiple sets of test values for the variables can be defined and run in bulk. Based on the test results, the prompt engineer can decide to add, remove, or rephrase certain parts of the prompt.
82
+
To test the behavior of the prompts, a test can be executed. The prompt engineer must provide test values for all variables defined in the prompts. Additionally, multiple sets of test values for the variables can be defined and run in bulk. Based on the test results, the prompt engineer can add, remove, or rephrase certain parts of the prompt.
83
83
84
-
#### Define context object
84
+
#### Define Context Object
85
85
86
-
If the prompt contains variables, your app must have an entity with attributes that match the variable names. An object of this entity functions as the context object, containing the context data and being passed when the chat completions operation is triggered. For more details, see the [Use the prompt in app logic section below](#app-logic). This object contains the actual values that will be inserted into the prompt where the variables were defined. This entity needs to be linked to the prompt in the Prompt Management UI If you create a new entity, run the app locally first to ensure it appears in the selection list. The `PromptAdmin` will see warnings on the **Prompt Version** details page if the attributes and variables don not match or if no entity has been selected for the prompt. Make sure that the attribute length of the context object is large enough to accommodate the actual values when logic is executed in the running app.
86
+
If the prompt contains variables, your app must have an entity with attributes that match the variable names. An object of this entity functions as the context object, containing the context data and being passed when the chat completion operation is triggered. For more details, see the [Use the prompt in the app logic section below](#app-logic). This object contains the actual values that will be inserted into the prompt where the variables were defined. This entity needs to be linked to the prompt in the Prompt Management UI If you create a new entity, run the app locally first to ensure it appears in the selection list. The `PromptAdmin` will see warnings on the Prompt Version details page if the attributes and variables do not match or if no entity has been selected for the prompt. Make sure that the attribute length of the context object is large enough to accommodate the actual values when logic is executed in the running app.
87
87
88
-
### Use the Prompt in App Logic {#app-logic}
88
+
### Use the Prompt in the App Logic {#app-logic}
89
89
90
-
After a number of quick iterations, a first version of the prompt is typically ready to be saved and integrated into the application logic to be tested from the end-user perspective. For this, you can add one of the operations from this module to your logic.
90
+
After several quick iterations, the first version of the prompt is typically ready to be saved and integrated into the application logic to be tested from the end-user perspective. For this, you can add one of the operations from this module to your logic.
91
91
92
92
#### Create a Version
93
93
94
-
New prompts will be created in the draft status by default, meaning they are still being worked on and can be tested using the prompt management module only. When it is ready to be integrated in the actual app (i.e., the logic that end users trigger), the prompt must be saved as a version. This will store a snapshot of the prompt texts. To select the active version for the prompt, use the threedot ({{% icon name="three-dots-menu-horizontal" %}}) menu on the prompt overview which says*Select prompt in use*.
94
+
New prompts will be created in the draft status by default, meaning they are still being worked on and can be tested using the prompt management module only. When it is ready to be integrated into the actual app (i.e., the logic that end users trigger), the prompt must be saved as a version. This will store a snapshot of the prompt texts. To select the active version for the prompt, use the three-dot ({{% icon name="three-dots-menu-horizontal" %}}) menu on the prompt overview which say*Select prompt in use*.
95
95
96
-
It then needs to be selected as the active version for the prompt. This can be done on the prompt overview, using the menu option behind the three horizontal dots that says*Select prompt in use*.
96
+
It then needs to be selected as the active version for the prompt. This can be done on the prompt overview, using the menu option behind the three horizontal dots that say*Select prompt in use*.
97
97
98
-
For a Single-Call type prompt, use `Get Prompt for Context Object`, which can be found in the **Toolbox** in Studio Pro while editing a microflow, under category **GenAI (Request Building)**. This operation returns both a system prompt and a user prompt strings, on a combined `PromptToUse` object. These string attributes can be passed to the chat completions operation. Retrieve the prompt (e.g. by name) and pass it with your custom context object to the operation. For an example of this pattern, see the product description generation example in the [GenAI Showcase app](https://marketplace.mendix.com/link/component/220475).
98
+
For a Single-Call type prompt, use `Get Prompt for Context Object`, which can be found in the **Toolbox** in Studio Pro while editing a microflow, under the category **GenAI (Request Building)**. This operation returns both a system prompt and a user prompt strings, on a combined `PromptToUse` object. These string attributes can be passed to the chat completions operation. Retrieve the prompt (e.g. by name) and pass it with your custom context object to the operation. For an example of this pattern, see the product description generation example in the [GenAI Showcase app](https://marketplace.mendix.com/link/component/220475).
99
99
100
100
For a conversational prompt, the chat context can be created based on the prompt in one operation. Use the `New Chat for Prompt` operation from the **Toolbox** under the **Conversational UI** category. Retrieve the prompt (e.g. by name) and pass it with your custom context object to the operation. Note that this sets the system prompt for the chat context, making it applicable to the entire (future) conversation. Similar to other chat context operations, an [action microflow needs to be selected](/appstore/modules/genai/conversational-ui/#action-microflow) for this microflow action.
101
101
102
102
With this microflow logic, the prompt version is ready to be tested from the end-user flow (in a local or test environment). The prompt can be exported/imported for transport to other environments if needed.
103
103
104
-
### Improve the prompt {#improve-prompt}
104
+
### Improve the Prompt {#improve-prompt}
105
105
106
-
When a prompt version is saved, there is a button to create a new draft version. This new draft can be used as a starting point to do small changes or improvements based on feedback, either from testing or when the functionality is live for a certain amount of time and the necessity to cover additional scenarios arises.
106
+
When a prompt version is saved, there is a button to create a new draft version. This new draft can be used as a starting point to make small changes or improvements based on feedback, either from testing or when the functionality is live for a certain amount of time and the necessity to cover additional scenarios arises.
107
107
108
-
#### Create multiple versions
108
+
#### Create Multiple Versions
109
109
110
-
The new draft version will initially have the exact same text as the latest version. The prompt texts can now be modified to cover for the additional scenarios. When the improved prompt is ready, it can be saved as a new version.
110
+
The new draft version will initially have the same text as the latest version. The prompt texts can now be modified to cover the additional scenarios. When the improved prompt is ready, it can be saved as a new version.
111
111
112
-
#### Manage in-use version per environment
112
+
#### Manage In-use Version per Environment
113
113
114
-
Each time a new versions of the prompt are created, a decision needs to be made regarding which version to use in the end-user logic. Mendix recommends to evaluating the in-use version as part of the test and release process. When importing the new prompts into other environments, selecting the in-use version is always a manual step and, therefore, a conscious decision.
114
+
Each time a new versions of the prompt are created, a decision needs to be made regarding which version to use in the end-user logic. Mendix recommends evaluating the in-use version as part of the test and release process. When importing the new prompts into other environments, selecting the in-use version is always a manual step and, therefore, a conscious decision.
115
115
116
116
## Technical Reference {#technical-reference}
117
117
@@ -123,4 +123,3 @@ The **Documentation** pane displays the documentation for the currently selected
123
123
2. Click the element for which you want to view the documentation.
0 commit comments