Development and Debugging
Currently, the Colang story designing and building environment is fairly limited, but will be improved on in the future.
Integrated Development Environment (IDE)
- We suggest using Visual Studio Code and the Colang highlighting extension (GitHub link) to help with highlighting Colang code.
- You can use the Visual Studio Code launch setting to run a Colang story with nemoguardrails in a python environment by pressing F5 (launch.json).
- You can show generated and received events by adding the
--verboseflag when starting nemoguardrails. This will also show all generated LLM prompts and responses. - To see even more details and show the internal run-time logs, use
--debug-level=INFOor set it equal toDEBUG.
Log and Print Statements
To help debugging your Colang flows, you can use the print statement print <expression> to print something to the standard output.
development_debugging/print_statement/main.co
Alternatively, use the log statement log <expression> to append to the logging shown in the verbose mode, which will appear as Colang Log <flow_instance_uid> :: <expression>.
Furthermore, the Colang function flows_info can be used to return more information about a flow instance:
development_debugging/flows_info/main.co
pretty_str converts the returned dictionary object to a nicely formatted string. If no parameter is provided to the function, it will return a dictionary containing all the currently active flow instances.
CLI Debugging Commands
The NeMo Guardrail CLI provides a couple of additional debugging commands that always start with the ! character:
All CLI debugging commands
Useful Flows
In the Colang Standard Library there are a couple of useful flows that can help in the development process of a Colang story:
notification of undefined flow start.
Sometimes it is easy to misspell a flow name. By default Colang will just generate a StartFlow(flow_id=<name_of_flow>) internal event. But if no flow with that name exists, nothing will happen. This can be confusing and difficult to find. To get help with that, you can activate the flow notification of undefined flow start. This will detect these cases, print and log a corresponding message, and optionally let the bot respond.
notification of unexpected user utterance.
This flow helps you detect if certain UtteranceUserAction.Finished() events are not matched to and therefore will create no bot response, which is rarely the case.
notification of colang errors.
When running a Colang story, there can be runtime errors due to invalid attribute access or LLM-related parsing errors. This error will generate a ColangError(error_type: str, error: str) event. Usually nothing will match to this event and the bot will remain silent. While debugging, this can be confusing. The flow notification of colang errors from the standard library will help make this more transparent by printing and logging a corresponding message and optionally letting the bot respond.