Moderation#

The Moderation screen is designed to manage sets of rules and individual Moderation rules that are applied to check or process messages in Sherpa AI Server.

No.Interface ElementDescription
1.“Rule Sets” blockDesigned to manage Moderation rule sets.
1.1.“Create” buttonOpens the form to create a new rule set.
1.2.“Refresh” buttonRefreshes the list of rule sets.
1.3.“Duplicate” buttonAllows creating a copy of the selected rule set.
1.4.“Delete Selected” buttonAllows deleting selected rule sets.
1.5.“Export to CSV” buttonExports the list of rule sets to a CSV file.
1.6.“Export to XLSX” buttonExports the list of rule sets to an XLSX file.
1.7.“Active” columnShows whether the rule set is enabled.
1.8.“Name” columnDisplays the name of the rule set.
1.9.“Description” columnDisplays the description of the rule set, if specified.
1.10.“Application Mode” columnDisplays the application mode of the rule set.
1.11.“Created” columnDisplays the date and time the rule set was created.
1.12.“Modified” columnDisplays the date and time the rule set was last modified.
1.13.Edit button Allows opening the selected rule set for editing.
1.14.Delete button Allows deleting a specific rule set.
2.“Rules” blockThe lower area of the screen designed to manage individual Moderation rules.
2.1.“Create” buttonOpens the form to create a new rule.
2.2.“Refresh” buttonRefreshes the list of rules.
2.3.“Delete Selected” buttonAllows deleting selected rules.
2.4.“Export to CSV” buttonExports the list of rules to a CSV file.
2.5.“Export to XLSX” buttonExports the list of rules to an XLSX file.
2.6.“Active” columnShows whether the rule is enabled.
2.7.“Name” columnDisplays the name of the rule.
2.8.“Description” columnDisplays the description of the rule, if specified.
2.9.“Trigger Type” columnDisplays the type of condition that triggers the rule.
2.10.“Actions” columnDisplays the action performed when the rule is triggered.
2.11.“Created” columnDisplays the date and time the rule was created.
2.12.“Modified” columnDisplays the date and time the rule was last modified.
2.13.Edit button Allows opening the selected rule for editing.
2.14.Delete button Allows deleting a specific rule.
2.15.Row count selection Allows specifying how many records will be displayed in the table on one page.
2.16.Record counter Shows the range of records displayed on the current page and the total number of records in the table.
2.17.Page navigation Allows navigating between pages of the table: to the first page, to the previous page, to the next page, or to the last page. Also displays the current page number and the total number of pages, for example Page 1 of 1.

Creating or changing a rule set requires a Role with access to Moderation and permission to create or update rule sets. Selecting individual Assistants also requires access to the Assistant list.

Create Rule Set#

To create a new rule set, you need to click the “Create” button in the “Rule Sets” section and fill out the opened form.

  • Name * — the name of the rule set.

  • Description — the description of the rule set.

  • Rule Application Mode * — a dropdown list that determines the order of processing multiple triggered rules for a single object. Value options:

    • Apply only the first triggered rule: Processing stops after the first rule (priority by order in the list).
    • Apply all triggered rules: Matching rules are processed sequentially until a “Block” or “Fixed Response” action stops processing.
  • Assistants — “None” excludes Assistants, “All” includes all Assistants in the Account, including future ones, and “Selected” includes only those chosen below.

  • Selected assistants — choose the Assistants in the Account when “Selected” is set. An Assistant can belong to only one selected set.

  • Ordinary chats — “None” excludes Chats without an Assistant. “All” includes existing and future ordinary Chats in the Account.

Each Account can have only one set for all Assistants and one for all ordinary Chats. An inactive set does not check messages. A set selected for an Assistant takes precedence over the set for all Assistants.

Example: to block the test word secret in ordinary Chats, choose “None” for “Assistants” and “All” for “Ordinary chats”. Add an active dictionary rule for secret with the “Block” action. After saving, send secret in an ordinary Chat. The message receives the blocked status.

Create Rule#

To create a new rule, you need to click the “Create” button in the “Rules” section and fill out the opened form.

Available trigger types in the Create Rule dialog, shown in Russian

Available trigger types when creating a rule. The interface is shown in Russian.

Trigger types in the Create Rule dialog at 768 pixels, shown in Russian

Create Rule dialog on a tablet. The interface is shown in Russian.

Trigger types in the Create Rule dialog at 360 pixels, shown in Russian

Create Rule dialog on a phone. The interface is shown in Russian.

No.Interface ElementDescription
1.field "Name"

Required field for entering the rule name.

If the field is not filled, it is highlighted in red, and the "OK" button remains inactive.

2.field "Description"Intended for entering a brief description of the Moderation rule.
3.block "Trigger"Contains settings for the condition under which the rule should be triggered.
3.1.field "Trigger Type"

Required dropdown field where the method for checking the user message is selected.

The selected Trigger type determines the condition under which the Moderation rule will be triggered and which additional fields will appear in the rule settings form:

  • value "Dictionary" - the rule is triggered if one of the words specified in the word list is found in the User's message. Suitable for simple checks based on predefined words or phrases.
  • value "Regular Expression" - the rule is triggered if the User's message matches the specified regular expression. Used for more flexible text pattern checks, such as formats of numbers, addresses, or stable text constructions.
  • value "Local Model" - the rule is triggered based on checking the message with a local Model. This option is used when a simple word list or regular expression is insufficient and a model assessment of the text content is required.
3.2.field "Word List"Intended for entering words whose presence will be checked in the User's request.
3.3.hint for the word list

Explains that:

  • the User's request is checked for the presence of the specified words;
  • only one word should be in each line of the list;
  • the check is case-insensitive;
  • the rule is triggered if any word from the list is found in the User's message.
4.block "Actions"Contains actions that the system will perform when the rule is triggered.
4.1.field "Action Type"

Required dropdown field where the action performed by the system when the Moderation rule is triggered is selected.

The selected action type determines what will happen to the User's message or the system's response after the specified Trigger is detected:

  • value "Block" - blocks the processing of the message or the execution of the further scenario when the rule is triggered. Used when the message should not be passed further or should be stopped.
  • value "Masking" - replaces found text fragments with hidden or anonymized values. Suitable for processing personal data, secrets, tokens, document numbers, and other sensitive information.
  • value "Rewrite" - modifies the text of the message according to specified rules before further processing. Used when it is necessary to automatically rephrase or clean the message.
  • value "Redirect" - redirects the processing of the message to another scenario, route, or handler. Applied when the request should be passed to another process upon triggering the rule.
  • value "Notification" - generates a notification when the rule is triggered. Used when it is necessary to record an event and inform the responsible user or system about it.
  • value "Fixed Response" - returns a predefined response instead of the standard message processing. Suitable for cases where template text is needed to respond to certain requests.
4.2.button to delete action Allows deleting the added action from the rule.
4.3.button Allows adding another action that will be performed when the rule is triggered.
5.field "Test Text"Intended for entering text on which the rule can be tested before saving.
6.button "Run Test"Starts the rule check on the entered test text.

If the button is inactive, the necessary data for testing is not filled in.
7.button "Cancel"Closes the window without creating a rule and without saving the entered data.
8.button "OK"Creates a rule with the specified parameters.

Active only if all required fields are completely filled.

If a rule with the "External Service" Trigger type or another unsupported type remains in a rule set, it does not check messages. An administrator must change its Trigger type to an available one, check the rule with "Run test", save it, and then send a test message through the Assistant. Other rules in the set continue to apply until this rule is corrected; the skipped rule is recorded in the server log.

Local model prompt and response check#

To configure a rule, you need access to the Moderation page and an available model. The Local Model trigger shows these fields:

  • “Model” — the model that checks the message.
  • “Prompt” — the checking instruction. {INPUT} is replaced with the message text. If the placeholder is absent, the text is appended to the prompt.
  • “Regexp to check response” — a regular expression matched against the model response. The rule triggers on a match.
  • “Temperature” — a value from 0 to 1. A value of 0 usually gives a more predictable response.

Create a separate rule for a safe check:

  1. Select the “Local Model” trigger and an available model.
  2. Enter Does the message contain personal data? Answer YES or NO. {INPUT} in “Prompt”.
  3. Enter ^YES$ in “Regexp to check response” and set the temperature to 0.
  4. Select “Block” under “Actions”. Enter a sample without real personal data in “Test text” and select “Run test”.

If the model responds with YES, the test shows a blocked message. Otherwise, the message passes the rule. The result depends on the selected model, so check both outcomes with sample data before using the rule.

For the “Rewrite” action, also select a “Model”. The “Prompt” of a new action already contains {INPUT}. You can edit it while keeping the placeholder at the intended position. “Temperature” controls how varied the model response is. The rewritten response replaces the original message text, so check the rule with “Run test” first. Previously saved prompts without {INPUT} also receive the message text at the end.

When a rule contains several actions, they run in the order shown. Each action receives the text produced by the previous one. For example, with “Masking” followed by “Rewrite”, the rewrite model receives masked text. In the reverse order, masking applies to the rewritten text.

“Block” and “Fixed Response” stop subsequent actions and rules in the set. The message is not sent to the response model. With a fixed response, the specified text appears in Chat. An “Alert” after masking or redirection does not undo the preceding action.

This behavior is enabled by default. If an administrator sets AISERVER_MODERATION_SEQUENTIAL_ACTIONS=0, the previous action processing order applies.

Edit Rule Set#

To view and edit the properties of a specific rule set, you need to select it from the list and click the button . After that, a form with the rule set settings will open, where you can make the necessary changes. The form includes “Assistants”, “Selected assistants”, and “Ordinary chats”. Changes to the scope apply to existing and future Chats. If the Assistant list fails to load, reopen the form before choosing “Selected”.

Edit Rule#

To view and edit the properties of a specific rule, you need to select it from the list and click the button . After that, a form with the rule settings will open, where you can make the necessary changes. There are no new fields in the previously created rule.

Check Saved Set in Assistant#

The "Run Test" button checks only the current rule in the form. To verify that the rule set works in Chat, check it through a test Assistant.

For testing, create a separate test rule set:

  1. Select the "Apply only the first triggered rule" application mode.
  2. Create an active rule in the set with the "Dictionary" Trigger.
  3. In the word list, enter secret.
  4. In the action, select "Fixed Response" and set the response text to Moderation Check.
  5. Save the rule by clicking "OK".
  6. In the rule set form, choose “Selected” in the “Assistants” field.
  7. In “Selected assistants”, choose the test Assistant and save the rule set.
  8. Open Chat with this Assistant and send the message secret.

To check an ordinary Chat, choose “All” in the test set’s “Ordinary chats” field. Open a Chat without an Assistant and send secret. With the “Fixed Response” action, the response should appear in that Chat’s history. Restore the previous scope after testing.

If everything is configured correctly, the Assistant will reply: Moderation Check.

Reload the page and open the same dialog: the fixed response should remain in the history.

You can also check that the rule really turns on and off:

  • send a regular message without the word secret — the Assistant should reply as usual;
  • disable the rule and send secret again — the fixed response should not appear;
  • disable the entire rule set — the rules in it should also stop applying.

If the check fails:

  1. If the rule passes the "Run Test" check but Chat returns an error, report the system version, error time, and the test set ID to the administrator. The administrator will check the logs and whether a fix is available for your version.
  2. If the set contains multiple rules, check the trigger order (numeric priority). In "Apply only the first triggered rule" mode, the rule with the lower numeric priority runs first. Inactive and deleted rules, as well as rules from other sets, should not be applied. After testing, restore the test Assistant settings and delete the test set.
  3. If a rule with the "Local Model" trigger type hangs, test it separately. A successful connection check and the list of Models confirm only endpoint availability, not generation speed. Give the administrator the error time, model name, and a short anonymized request example. The administrator will check generation, the queue, and the LLM server logs. Do not disable moderation protection on the working Assistant just to bypass the error.
  4. If the test shows blocked and a fixed response is set, but the response does not appear in Chat or is replaced by the Model response, provide the administrator with the system version and an anonymized request example. The "Block" action without fixed text stops message processing but does not add an empty response. The "Masking" action changes the input text and then passes it to the Assistant for normal processing.
  5. Editing a blocked message in history does not reprocess it. To continue the conversation, send a new message that passes the Moderation rules.

Regular expression checks#

For a rule with the "Regular expression" trigger, enter one expression per line in the "Regular Expressions List" field. Matching is case-insensitive for Cyrillic and Latin letters. You can enter / without escaping it. For this example, add two lines: да and https?://\S+.

  1. Select the "Masking" action and set the replacement text to [MASKED].
  2. Enter Да https://example.test in the "Test text" field and select "Run test".
  3. Check that the result contains [MASKED] in place of each matching fragment. "Run test" checks the rule before it is saved.

If an expression has invalid syntax, the test reports an error and saving the rule is rejected with a notification. Correct the expression and test again. If masking cannot process a message while the rule is running, message processing is blocked. The original text is not sent to the Assistant as masked text.