|
| 1 | +-- @version: 11.9+ |
| 2 | +-- ============================================================================ |
| 3 | +-- Agent Editor: Model Document Examples |
| 4 | +-- ============================================================================ |
| 5 | +-- |
| 6 | +-- This file demonstrates the MDL syntax for managing agent-editor Model |
| 7 | +-- documents. Models represent LLM configurations created in the Mendix |
| 8 | +-- Studio Pro Agent Editor. They are stored as CustomBlobDocuments with |
| 9 | +-- CustomDocumentType = "agenteditor.model". |
| 10 | +-- |
| 11 | +-- A Model document references a String constant that holds the |
| 12 | +-- Mendix Cloud GenAI Portal resource key. At runtime, the |
| 13 | +-- AgentEditorCommons.ASU_AgentEditor after-startup microflow reads |
| 14 | +-- the constant and creates the corresponding GenAICommons.DeployedModel. |
| 15 | +-- |
| 16 | +-- Features demonstrated: |
| 17 | +-- - CREATE MODEL (minimal: Provider + Key) |
| 18 | +-- - CREATE MODEL (with Portal-populated metadata) |
| 19 | +-- - LIST MODELS [IN Module] |
| 20 | +-- - DESCRIBE MODEL |
| 21 | +-- - DROP MODEL |
| 22 | +-- |
| 23 | +-- Prerequisites: |
| 24 | +-- - A String constant must exist to hold the Portal key |
| 25 | +-- - AgentEditorCommons module must be installed |
| 26 | +-- - Encryption module must be configured (32-char key) |
| 27 | +-- - ASU_AgentEditor registered as after-startup microflow |
| 28 | +-- |
| 29 | +-- ============================================================================ |
| 30 | + |
| 31 | +CREATE MODULE ModelTest; |
| 32 | + |
| 33 | +-- ============================================================================ |
| 34 | +-- Setup: Create the key constant that the Model will reference |
| 35 | +-- ============================================================================ |
| 36 | + |
| 37 | +CREATE CONSTANT ModelTest."GPT4Key" |
| 38 | + TYPE String |
| 39 | + DEFAULT ''; |
| 40 | +/ |
| 41 | + |
| 42 | +CREATE CONSTANT ModelTest."ClaudeKey" |
| 43 | + TYPE String |
| 44 | + DEFAULT ''; |
| 45 | +/ |
| 46 | + |
| 47 | +-- MARK: Create |
| 48 | + |
| 49 | +-- ============================================================================ |
| 50 | +-- LEVEL 1: Basic Model Creation |
| 51 | +-- ============================================================================ |
| 52 | + |
| 53 | +/** |
| 54 | + * Level 1.1: Minimal model — just Provider and Key |
| 55 | + * |
| 56 | + * This is the typical CREATE MODEL statement. The Provider is always |
| 57 | + * MxCloudGenAI (the only supported value in current Mendix versions). |
| 58 | + * The Key references a String constant that will hold the Portal key. |
| 59 | + * |
| 60 | + * After creation, the model appears in Studio Pro's Agent Editor and |
| 61 | + * can be selected when configuring an Agent. |
| 62 | + */ |
| 63 | +CREATE MODEL ModelTest."GPT4Model" ( |
| 64 | + Provider: MxCloudGenAI, |
| 65 | + Key: ModelTest.GPT4Key |
| 66 | +); |
| 67 | +/ |
| 68 | + |
| 69 | +/** |
| 70 | + * Level 1.2: Second model referencing a different key |
| 71 | + * |
| 72 | + * Projects commonly have multiple models (e.g., GPT-4 for complex tasks, |
| 73 | + * Claude for document analysis). Each references its own key constant. |
| 74 | + */ |
| 75 | +CREATE MODEL ModelTest."ClaudeModel" ( |
| 76 | + Provider: MxCloudGenAI, |
| 77 | + Key: ModelTest.ClaudeKey |
| 78 | +); |
| 79 | +/ |
| 80 | + |
| 81 | +-- ============================================================================ |
| 82 | +-- LEVEL 2: Model with Portal-Populated Metadata |
| 83 | +-- ============================================================================ |
| 84 | + |
| 85 | +/** |
| 86 | + * Level 2.1: Model with display name and key name |
| 87 | + * |
| 88 | + * These fields are normally populated by Studio Pro when the user clicks |
| 89 | + * "Test Key" against the Mendix Cloud GenAI Portal. They can be provided |
| 90 | + * in MDL for round-trip preservation (e.g., when DESCRIBE output is |
| 91 | + * re-executed), but setting them manually has no functional effect. |
| 92 | + */ |
| 93 | +CREATE MODEL ModelTest."ConfiguredModel" ( |
| 94 | + Provider: MxCloudGenAI, |
| 95 | + Key: ModelTest.GPT4Key, |
| 96 | + DisplayName: 'GPT-4 Turbo (128K)', |
| 97 | + KeyName: 'prod-gpt4-turbo', |
| 98 | + Environment: 'production' |
| 99 | +); |
| 100 | +/ |
| 101 | + |
| 102 | +-- MARK: List |
| 103 | + |
| 104 | +-- ============================================================================ |
| 105 | +-- LEVEL 3: List Models |
| 106 | +-- ============================================================================ |
| 107 | + |
| 108 | +-- List all models across all modules |
| 109 | +LIST MODELS; |
| 110 | +/ |
| 111 | + |
| 112 | +-- List models in a specific module |
| 113 | +LIST MODELS IN ModelTest; |
| 114 | +/ |
| 115 | + |
| 116 | +-- SHOW also works (deprecated alias for LIST) |
| 117 | +SHOW MODELS IN ModelTest; |
| 118 | +/ |
| 119 | + |
| 120 | +-- MARK: Describe |
| 121 | + |
| 122 | +-- ============================================================================ |
| 123 | +-- LEVEL 4: Describe Model |
| 124 | +-- ============================================================================ |
| 125 | + |
| 126 | +-- Describe produces round-trippable MDL. User-set fields (Provider, Key) |
| 127 | +-- come first; Portal-populated fields only appear when non-empty. |
| 128 | +DESCRIBE MODEL ModelTest.GPT4Model; |
| 129 | +DESCRIBE MODEL ModelTest.ConfiguredModel; |
| 130 | + |
| 131 | +-- MARK: Drop |
| 132 | + |
| 133 | +-- ============================================================================ |
| 134 | +-- LEVEL 5: Drop Model |
| 135 | +-- ============================================================================ |
| 136 | + |
| 137 | +-- Drop a model by qualified name. |
| 138 | +-- The underlying CustomBlobDocument is removed from the project. |
| 139 | +DROP MODEL ModelTest.ConfiguredModel; |
| 140 | +/ |
| 141 | + |
| 142 | +-- Verify it's gone |
| 143 | +LIST MODELS IN ModelTest; |
| 144 | +/ |
| 145 | + |
| 146 | +-- ============================================================================ |
| 147 | +-- LEVEL 6: Error Cases |
| 148 | +-- ============================================================================ |
| 149 | + |
| 150 | +-- These statements produce errors (commented out to not block the script): |
| 151 | + |
| 152 | +-- Duplicate model name: |
| 153 | +-- CREATE MODEL ModelTest.GPT4Model (Provider: MxCloudGenAI, Key: ModelTest.GPT4Key); |
| 154 | +-- → Error: model already exists: ModelTest.GPT4Model |
| 155 | + |
| 156 | +-- Missing constant: |
| 157 | +-- CREATE MODEL ModelTest.BadModel (Provider: MxCloudGenAI, Key: ModelTest.NoSuchConst); |
| 158 | +-- → Error: CREATE MODEL ModelTest.BadModel: constant not found: ModelTest.NoSuchConst |
| 159 | + |
| 160 | +-- Drop non-existent model: |
| 161 | +-- DROP MODEL ModelTest.DoesNotExist; |
| 162 | +-- → Error: model not found: ModelTest.DoesNotExist |
| 163 | + |
| 164 | +-- ============================================================================ |
| 165 | +-- Cleanup |
| 166 | +-- ============================================================================ |
| 167 | + |
| 168 | +DROP MODEL ModelTest.GPT4Model; |
| 169 | +DROP MODEL ModelTest.ClaudeModel; |
| 170 | +/ |
0 commit comments