RAG Action
This Action Type allows you to browse RAG files available in your system and retrieve text fragments corresponding to your question/query.
Step 1. Press the Rag Action button at the bottom of an Action Group. New action will be created.
Step 2. Setup new action block step by step:
A – Help Dialog
For guidance on the action and some hints, click the Information Icon.
B – RAG Destination
You can choose between using the Default RAG Destination connection, which is assigned to the current AI Model in the RAG Settings section, or selecting a specific one from the list for this action.
C – Input Prompt
The Input Prompt is where you include the user phrase. You can enhance the {{user_phrase}} by adding additional text or memory parameters.
Example Input Prompt 1: {{user_phrase}}
Example Input Prompt 2: Answer this question: {{user_phrase}} in context of {{memory.rt_leave_request_type}}.
Step 3. Add filtering attributes (optional):
This feature allows you to limit the RAG search by specific attributes associated with the documents in the RAG database. To filter by attributes, use the Add Condition button. You can also create advanced filtering by combining multiple conditions within Condition Sets.
NOTE: To select an attribute from the list, it must first be added to the corresponding RAG model in the ML Models Hub application.
Press Add Condition button:
A table will appear with one row filled in. Mark the checkbox on the left of the first row with AND/OR, and press the Add Condition button.
Select an Attribute, Operation, and Value from expandable lists.
You can select only Attributes and Values that are present in RAG Document HUB application and correspond with existing files.
You can use search when selecting Attribute or Value:
Example 1:
Use only documents that have:
“Line of Business” Attribute equal to “Staff” OR
“Line of Business” Attribute equal to “HR”:
Example 2 :
Use only documents that have:
“Line of Business” Attribute equal to “Staff” OR
“Line of Business” Attribute equal to “HR”:
AND
“Approval Date” greater than “Jan 1, 2025” AND
“Version Number” greater than 1.
Those are existing documents in RAG Document HUB after applying those filters :
Step 4. Additional Parameters.
Parameters for the RAG Destination are applied by default. You can view these parameters in the AI Model Configurator application, in RAG Settings section. To customize the AI’s behavior further, you can redefine existing parameters or add new ones using Add Parameter function.
Available Parameters:
- chunks: sets the maximum number of text segments (chunks) that will be retrieved and used for generating a response to the user’s query. Expected Format: Integer (e.g., 3, 5)
- max_distance: sets the relevance threshold for how closely chunks must match the query. Lower values yield more precise results, higher values include broader context. Expected Format: Integer (e.g., 30, 10)
NOTE: Changing default parameters can significantly influence the AI Model’s performance and responses. Therefore, it is recommended to proceed with caution when making changes.
Step 5. Output Memory Parameter.
The result of the RAG search will be saved as the array structure in the memory parameter specified in the Output Parameter, rt_rag_output by default. You can change the output name to your liking.
The RAG reply structure (with default rt_rag_output parameter name):
[ { "chunkText": "", // Extracted text segment (chunk) from the document matching the search criteria. "distance": "", // Relevance score indicating how closely the chunk matches the search query (lower values = closer match). "docGUID": "", // Unique identifier (GUID) of the document from which the chunk was extracted. "docName": "", // Name of the document containing the extracted chunk. "link": "", // URL or link to access the document directly. "ragGUID": "", // Unique identifier (GUID) for the RAG document. "startPos": "" // Starting position of the extracted text chunk within the document, indicating where the relevant text begins. } ]
To refer to the RAG reply structure, use the following syntax: {{memory.rt_rag_output.[n].field_name}}, where n — ordinal number of element in the array starting from 0, field_name — name of the field of the array element.
Here we display the retrieved chunks in Text Action Block:
Save your changes when done editing.
Postprocessing Hints:
Since the reply by the RAG search engine is saved in a memory parameter there is a full flexibility of referring to the RAG search results. There are several most common options of the RAG search result post-processing.
1. Raw output of RAG search results (can be added as a set of messages of text type): you can display chunks as a text message.
I was able to find the following facts according to your search request:
**Fact number 1**: {{memory.rt_rag_output.[0].chunkText}}
**Document Name**: {{memory.rt_rag_output.[0].docName}}
**Document Link**: {{memory.rt_rag_output.[0].link}}
**Fact number 2**: {{memory.rt_rag_output.[1].chunkText}}
**Document Name**: {{memory.rt_rag_output.[1].docName}}
**Document Link**: {{memory.rt_rag_output.[1].link}}
**Fact number 3**: {{memory.rt_rag_output.[2].chunkText}}
**Document Name**: {{memory.rt_rag_output.[2].docName}}
**Document Link**: {{memory.rt_rag_output.[2].link}}
NOTE: You may format and refer to the elements of the RAG output structure as required by the specific of your business scenario.
2. RAG reply processing by Gen AI: use retrieved chunks as a source for Generative AI response.
- Add a Generative AI Action after your RAG action.
- Add a Processing Instruction: In the Generative AI Action, include an instruction in the Instruction field to define how the RAG results should be processed. Use the memory parameter {{memory.rt_rag_output}} to refer to RAG search results.
Instruction Template: If you need a starting point, use the template below as an example. Copy and paste it into the Instruction field of your Generative AI Action:
Template 1:
Please create a reply to the Input Prompt using the provided chunks and output them in the following structure:
**Fact number …**: [summary of each chunkText]
**Document Name**: [docName]
**Link**: [Link]
Start with some general phrase, like ‘Here are the facts according to your request’ or similar.
There should be as many facts, document names and links as chunkText elements. If no facts, reply that nothing was found according to the request.
Facts: {{memory.rt_rag_output}}
Template 2:
Generate a consistent reply to the Input Prompt based on the chunkTexts of the following facts: {{memory.rt_rag_output}}. Don’t include any additional information in the reply.
NOTE: You can customize the instruction to fit your specific needs. This template is just an example to help you get started.