The server, the chat command and the rail library
This course used NeMo Guardrails from Python, one config at a time. The same package runs as a server, has a command line, and ships a library of ready-made rails.
The command line
Installing the package adds a nemoguardrails command. nemoguardrails chat --config=. opens an interactive conversation with a config folder. server starts an HTTP server that other applications call, actions-server runs actions in a separate process, eval evaluates a configuration, and convert moves Colang files from an older version to the latest.
import subprocess
import sys
out = subprocess.run([sys.executable, "-m", "nemoguardrails", "--help"],
capture_output=True, text=True).stdout
for name in ["chat", "server", "actions-server", "eval", "convert"]:
print(name, name in out)The rail library
import os
import nemoguardrails.library as library
folders = sorted(name for name in os.listdir(os.path.dirname(library.__file__))
if not name.startswith("_") and "." not in name)
print(len(folders))
print(", ".join(folders[:12]))self_check is where self check input and self check output came from. The other folders include jailbreak and injection detection, content safety models such as Llama Guard, fact-checking and hallucination checks, sensitive data detection, and integrations with outside services. Each is switched on the way lesson 13 switched on self check input: a flow name in config.yml, plus whatever model or key the rail needs.
Other things this course did not cover
Retrieval rails, the retrieval list in config.yml, check the chunks fetched for a retrieval-augmented answer. stream_async streams a reply as it is written. Colang 2.0 is a rewrite of the language; colang_version still defaults to 1.0, which is what this course used throughout.
- Run
nemoguardrails chat --config=.in a config folder from this course and hold a conversation. - Open
library/jailbreak_detectionand find the flow names it defines. - Print
RailsConfig.from_content(yaml_content="models: []").colang_version.
Little by little, you're building something great.