|
| 1 | +Agents |
| 2 | +====== |
| 3 | + |
| 4 | +AI agent documents (Model, Knowledge Base, Consumed MCP Service, Agent) |
| 5 | +require the AgentEditorCommons marketplace module and Mendix 11.9+. |
| 6 | + |
| 7 | +PREREQUISITES |
| 8 | +------------- |
| 9 | + |
| 10 | + 1. AgentEditorCommons module installed from the marketplace |
| 11 | + 2. Encryption module configured with a 32-character key |
| 12 | + 3. ASU_AgentEditor registered as the after-startup microflow |
| 13 | + |
| 14 | + Create constants to hold the API keys first: |
| 15 | + |
| 16 | + CREATE CONSTANT Module.ModelApiKey TYPE String DEFAULT ''; |
| 17 | + |
| 18 | +SHOW / LIST |
| 19 | +----------- |
| 20 | + |
| 21 | + LIST MODELS [IN Module]; |
| 22 | + LIST KNOWLEDGE BASES [IN Module]; |
| 23 | + LIST CONSUMED MCP SERVICES [IN Module]; |
| 24 | + LIST AGENTS [IN Module]; |
| 25 | + |
| 26 | + DESCRIBE MODEL Module.Name; |
| 27 | + DESCRIBE KNOWLEDGE BASE Module.Name; |
| 28 | + DESCRIBE CONSUMED MCP SERVICE Module.Name; |
| 29 | + DESCRIBE AGENT Module.Name; |
| 30 | + |
| 31 | +CREATE MODEL |
| 32 | +------------ |
| 33 | + |
| 34 | + CREATE MODEL Module.MyModel ( |
| 35 | + Provider: MxCloudGenAI, |
| 36 | + Key: Module.ModelApiKey |
| 37 | + ); |
| 38 | + |
| 39 | + Provider defaults to MxCloudGenAI when omitted. |
| 40 | + Key must refer to a String constant in the project. |
| 41 | + |
| 42 | +CREATE KNOWLEDGE BASE |
| 43 | +--------------------- |
| 44 | + |
| 45 | + CREATE KNOWLEDGE BASE Module.ProductDocs ( |
| 46 | + Provider: MxCloudGenAI, |
| 47 | + Key: Module.KBApiKey |
| 48 | + ); |
| 49 | + |
| 50 | +CREATE CONSUMED MCP SERVICE |
| 51 | +---------------------------- |
| 52 | + |
| 53 | + CREATE CONSUMED MCP SERVICE Module.WebSearch ( |
| 54 | + ProtocolVersion: v2025_03_26, |
| 55 | + Version: '1.0', |
| 56 | + ConnectionTimeoutSeconds: 30, |
| 57 | + Documentation: 'Web search MCP server' |
| 58 | + ); |
| 59 | + |
| 60 | +CREATE AGENT (simple) |
| 61 | +--------------------- |
| 62 | + |
| 63 | + CREATE AGENT Module.Summarizer ( |
| 64 | + UsageType: Task, |
| 65 | + Model: Module.MyModel, |
| 66 | + SystemPrompt: 'Summarize in 3 sentences.', |
| 67 | + UserPrompt: 'Enter text.' |
| 68 | + ); |
| 69 | + |
| 70 | + UsageType values: Task, Conversational |
| 71 | + |
| 72 | +CREATE AGENT (with variables and tools) |
| 73 | +---------------------------------------- |
| 74 | + |
| 75 | + CREATE AGENT Module.ResearchAssistant ( |
| 76 | + UsageType: Conversational, |
| 77 | + Description: 'Research assistant', |
| 78 | + Model: Module.MyModel, |
| 79 | + MaxTokens: 16384, |
| 80 | + Temperature: 0.7, |
| 81 | + TopP: 0.9, |
| 82 | + ToolChoice: Auto, |
| 83 | + Variables: ("Language": EntityAttribute), |
| 84 | + SystemPrompt: $$You are a research assistant. |
| 85 | +Respond in {{Language}}.$$, |
| 86 | + UserPrompt: 'Ask me anything.' |
| 87 | + ) |
| 88 | + { |
| 89 | + MCP SERVICE Module.WebSearch { |
| 90 | + Enabled: true |
| 91 | + } |
| 92 | + |
| 93 | + KNOWLEDGE BASE ProductKB { |
| 94 | + Source: Module.ProductDocs, |
| 95 | + Collection: 'product-docs', |
| 96 | + MaxResults: 5, |
| 97 | + Description: 'Product documentation', |
| 98 | + Enabled: true |
| 99 | + } |
| 100 | + |
| 101 | + TOOL MyMicroflowTool { |
| 102 | + Description: 'Fetch customer data', |
| 103 | + Enabled: true |
| 104 | + } |
| 105 | + }; |
| 106 | + |
| 107 | + Use $$...$$ for multi-line prompts. Single-quoted strings cannot span lines. |
| 108 | + Variables: ("Key": EntityAttribute) binds entity attributes. |
| 109 | + Variables: ("Key": String) binds plain string values. |
| 110 | + |
| 111 | +DROP |
| 112 | +---- |
| 113 | + |
| 114 | + DROP AGENT Module.Name; |
| 115 | + DROP CONSUMED MCP SERVICE Module.Name; |
| 116 | + DROP KNOWLEDGE BASE Module.Name; |
| 117 | + DROP MODEL Module.Name; |
| 118 | + |
| 119 | + Always drop Agents before the Model, Knowledge Base, or MCP Service they reference. |
| 120 | + |
| 121 | +NOTES |
| 122 | +----- |
| 123 | + |
| 124 | + Portal-populated metadata fields (DisplayName, KeyName, KeyID, Environment, |
| 125 | + ResourceName, DeepLinkURL) are managed by the Mendix portal and should not |
| 126 | + be set manually in CREATE statements. |
| 127 | + |
| 128 | + The documentId field is an opaque agent-internal ID populated at |
| 129 | + runtime by ASU_AgentEditor. You do not need to set it. |
| 130 | + |
| 131 | + Cross-document references are validated at execute time: the Model, Knowledge |
| 132 | + Base, and MCP Service documents must exist before creating an Agent that |
| 133 | + references them. |
0 commit comments