Skip to content

Commit 78d840b

Browse files
Merge pull request mendix#9060 from mendix/kv-mxcloud-rag
SAS-1115: updated Tool, Function, KnowledgeBaseRetrieval
2 parents d581a61 + 0e33a25 commit 78d840b

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

content/en/docs/appstore/use-content/platform-supported-content/modules/genai/mendix-cloud-genai/Mx GenAI Connector.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,13 @@ The microflow activity [Chat Completions (without history)](/appstore/modules/ge
117117

118118
The microflow activity [Chat completions (with history)](/appstore/modules/genai/genai-for-mx/commons/#chat-completions-with-history) supports more complex use cases where a list of (historical) messages (for example, the conversation or context so far) is sent as part of the request to the LLM.
119119

120-
#### Chat Completions (Retrieve & Generate)
120+
#### Retrieve & Generate {#retrieve-and-generate}
121121

122-
The microflow activity `Retrieve and Generate (MxCloud, without history)` simplifies `Retrieve and Generate` use cases without history. By providing a user prompt, the knowledge base is searched for similar knowledge chunks, which are then passed to the model. The model is instructed to base its response on the retrieved knowledge while referring to the source used to generate the response. This operation requires a [Request](/appstore/modules/genai/genai-for-mx/commons/#request) which is associated to a `RetrieveAndGenerateRequest_Extension` pointing to a `MxKnowledgebaseConnection` object. Please use the flow shown below as orientation when setting up your logic to make sure that all is implemented as required:
122+
To use retrieval and generation in a single operation, an internally predefined tool can be added to the [Request](/appstore/modules/genai/genai-for-mx/commons/#request) via the `Tools: Add Mendix Cloud Knowledge Base` action . The model can then decide whether to use the [knowledge base retrieval](/appstore/modules/genai/genai-for-mx/commons/#knowledge-base-retrieval) tool when handling the request. This functionality is supported in both with-history and without-history operations. Additionally, you may apply optional filters, such as `MaxNumberOfResults` or `MinimumSimilarity`, or pass a [MetadataCollection](/appstore/modules/genai/genai-for-mx/commons/#metadatacollection-entity). The optional `Description` can help the model understand the knowledge base content and decide whether it should be called in the current chat context.
123123

124124
{{< figure src="/attachments/appstore/platform-supported-content/modules/genai/mxgenAI-connector/MxGenAIConnector_ConfigureRAG.png" >}}
125125

126-
A `SystemPrompt` can be provided through the `Request` and other filter options can be set when initializing the `RetrieveAndGenerateRequest_Extension` (for example through metadata).
127-
128-
The returned `Response` includes [References](/appstore/modules/genai/genai-for-mx/commons/#reference) if the model used them to generate its response. In some cases, a knowledge chunk consists of two texts: one for the semantic search step and another for the generation step. For example, when solving a problem based on historical solutions, the semantic search identifies similar problems using their descriptions, while the generation step produces a solution based on the corresponding historical solutions. In those cases, you can add [MetaData](/appstore/modules/genai/genai-for-mx/commons/#chunkcollection-add-knowledgebasechunk) with the key `knowledge` to the chunks during the insertion stage, allowing the model to base its response on the specified metadata rather than the input text.
126+
The returned `Response` includes [References](/appstore/modules/genai/genai-for-mx/commons/#reference) if the model used them to generate its response. In some cases, a knowledge chunk consists of two texts: one for the semantic search step (retrieval) and another for the generation step. For example, when solving a problem based on historical solutions, the semantic search identifies similar problems using their descriptions, while the generation step produces a solution based on the corresponding historical solutions. In those cases, you can add [MetaData](/appstore/modules/genai/genai-for-mx/commons/#chunkcollection-add-knowledgebasechunk) with the key `knowledge` to the chunks during the insertion stage, allowing the model to base its response on the specified metadata rather than the input text (only the knowledge is passed to the model).
129127

130128
Additionally, to utilize the `Source` attribute of the references, you can include `MetaData` with the key `sourceUrl`. Finally, the `HumanReadableId` of a chunk is used to display the reference's title in the response.
131129

content/en/docs/appstore/use-content/platform-supported-content/modules/genai/reference-guide/genai-for-mendix.md/genai-commons.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,25 @@ A tool in the tool collection. This is sent along with the request to expose a l
159159
| `Name` | The name of the tool to call. This is used by the model in the response to identify which function needs to be called. |
160160
| `Description` | An optional description of the tool, used by the model in addition to the name attribute to choose when and how to call the tool. |
161161
| `ToolType` | The type of the tool. Refer to the documentation supplied by your AI provider for information about the supported types. |
162+
| `Microflow` | The name (string) of the microflow that this tool represents. |
162163

163164
#### `Function` {#function}
164165

165166
A tool of the type *function*. This is a specialization of [Tool](#tool) and represents a microflow in the same Mendix application. The return value of this microflow when executed as a function is sent to the model in the next iteration and hence must be of type String.
166167

167-
| Attribute | Description |
168-
| --- | --- |
169-
| `Microflow` | The name (string) of the microflow that this function represents. |
170-
171168
{{% alert color="info" %}}
172169
Since this microflow runs in the context of the user, you can make sure that it only shows data that is relevant to the current user.
173170
{{% /alert %}}
174171

172+
#### `KnowledgeBaseRetrieval` {#knowledge-base-retrieval}
173+
174+
A tool of the type *function*. This is a specialization of [Tool](#tool) and represents a microflow in the same Mendix application. It is typically used internally inside of connector operations to enable the model with a knowledge base retrieval.
175+
176+
| Attribute | Description |
177+
| --- | --- |
178+
| `MinimumSimilarity` | Specifies the minimum similarity score (usually 0,0 - 1,0) of the passed chunk and the knowledge chunks in the knowledge base. |
179+
| `MaxNumberOfResults` | Specifies the maximum number of results that should be retrieved from the knowledge base. |
180+
175181
#### `StopSequence` {#stopsequence}
176182

177183
For many models, `StopSequence` can pass a list of character sequences (for example a word) along with the request. The model will stop generating content when a word of that list occurs next.
16.5 KB
Loading

0 commit comments

Comments
 (0)