- Begin a new flow.
- Terminate the current flow.
- Intercept user messages to bypass the current collection step.
- Assign a specified value to a slot.
- Request clarification.
- Provide a chitchat-style response, whether predefined or generated.
- Deliver a free-form, knowledge-based response.
- Transition the conversation to a human operator.
- Signal an internal error in handling the dialogue.
- Indicate a failure in generating any commands.
For more details on all command generator types, advanced configurations, and usage examples,
see the LLM Command Generators reference.
What Is the CompactLLMCommandGenerator?
The CompactLLMCommandGenerator is the simplest LLM-based approach for converting user messages into commands. It operates on a single prompt that encapsulates:- Conversation History: The full or partial conversation so far, including user and assistant messages.
- Active Flow and Slots: Which flow is currently on top of the dialogue stack and which slot (if any) is currently being asked for.
- Relevant Flows: A subset of the flows in your assistant that are likely relevant to the user’s request (handled automatically by CALM’s flow retrieval mechanism).
- Patterns / Repairs: Predefined flows or patterns that can “interrupt” if the user changes their mind, wants to cancel, or triggers some other conversation repair scenario.
Flow Retrieval
By default, CALM does not include all possible flows in the LLM prompt. Instead, it matches the incoming user message to each flow and includes only the top matching flows in the prompt. This keeps the prompt size manageable (and your costs lower). If you do want to disable or tweak flow retrieval, or always include certain flows, you can adjust that in your assistant configuration. For more details, see the Flow Retrieval reference.Customizing the Prompt Template
One of the main benefits of an LLM-based approach is in-context learning—that is, the ability to guide the model through instructions and context in the prompt. By default, the CompactLLMCommandGenerator uses a built-in prompt template that dynamically assembles relevant flows, the current conversation, and other context. However, you can override and customize this template to further tailor the model’s behavior.When Should You Customize?
- Flow Descriptions Aren’t Enough Usually, you can steer the LLM by enriching your flows with clear, unambiguous descriptions and step-by-step instructions. But if you find the model still isn’t producing the commands you expect, or if you have domain-specific language the model often confuses, you may want to go further and rewrite the template.
- You Want Specific Formatting or Additional Examples Suppose you need to show the LLM a set of few-shot examples or domain-specific instructions that can’t be captured solely in the flow/slot descriptions. A custom prompt template gives you full control over how that context appears.
How to Customize
-
Create a Jinja2 Template
You’ll provide a custom
.jinja2file that contains the static text you want plus references to dynamic variables (like{{ current_flow }},{{ flow_slots }}, etc.). -
Reference That File in Your config.yml
Under
CompactLLMCommandGenerator, set theprompt_templateproperty:
config.yml
-
Leverage Available Variables
In your Jinja2 file, you have access to multiple variables, such as:
You can iterate over lists to print out details about flows or slots. For example:
prompts/my_custom_generator.jinja2
-
Make Your Template Clear and Consistent
- If your slot descriptions are long or bullet-pointed, consider adjusting how you render them. Use numbered lists or add separators so the LLM easily distinguishes the slot’s name from its instructions.
- Keep the entire prompt in one language if your assistant is multilingual or works in a language other than English. Smaller LLMs often do better if the entire prompt is consistently in a single language.
Important Note on Customizing the Command Set
For more technical details on configuration parameters, advanced prompt tuning, or combining multiple Command Generators, head over to the Command Generators reference. While CALM’s Command Generator is designed to be flexible, the Rasa team actively tests and maintains a fixed set of built-in commands (e.g.,StartFlowCommand, CancelFlowCommand, SetSlotCommand, etc.) to ensure the highest level of performance and accuracy. If you override or replace these built-in commands:
- Reduced Accuracy Guarantees We can’t guarantee that your assistant will maintain the same level of accuracy if you remove or rename these commands. Our tests and improvements assume that these commands exist in your system.
- Potential Maintenance Overheads Custom commands require additional testing to ensure they behave consistently across different user inputs. You’ll need to invest in ongoing QA to match the quality of the maintained commands.
- Possibility of Breaking Changes Future updates or improvements to CALM may assume the presence of these default commands. If you’ve drastically modified them, you could need to refactor your assistant for compatibility.
How to customize existing commands
If a use case still requires customization of commands, then here is the recommended way:-
Override an existing command class
Identify the existing command you want to change. Define a new Python class inheriting from the corresponding command class.
Override the following methods:
command- provides Rasa with the unique identifier of your custom command.from_dict- handles the deserialization of the command from the JSON object stored in the tracker.from_dsl- converts the parsed output from the LLM output into a command.to_dsl- specifies how the command is represented when serialized back into the DSL format.regex_pattern- used by Rasa to parse and recognize your custom command name from the output generated by the LLM.__eq__- logic that determines whether two command instances are equal.
Commandabstract class and adhere to thePromptCommandprotocol. For example, to customize the name of theHumanHandoffCommandclass used in your prompt, create the following:
-
Override the existing command behavior
If you also want to update the command behavior, override the
run_command_on_trackermethod within your class.
-
Create custom command generator
Create a custom command generator class by extending Rasa’s default command generator. Override its
parse_commandsmethod as follows to handle your customized commands:
custom_command_generator.py
- Update the prompt template Create the custom prompt template that uses your new command name explicitly. For example:
custom_prompt_template.jinja2
- Update the
config.ymlto utilize the custom command generator and the new prompt template
config.yml