@@ -387,86 +387,23 @@ def _is_usage_stats_enabled() -> bool:
387387 return True
388388
389389
390- _KNOWN_BUILTIN_FLOWS = {
391- "activefence moderation on input" : "activefence" ,
392- "activefence moderation on input detailed" : "activefence" ,
393- "activefence moderation on output" : "activefence" ,
394- "ai defense inspect prompt" : "ai_defense" ,
395- "ai defense inspect response" : "ai_defense" ,
396- "alignscore check facts" : "factchecking" ,
397- "autoalign check input" : "autoalign" ,
398- "autoalign check output" : "autoalign" ,
399- "autoalign factcheck output" : "autoalign" ,
400- "autoalign groundedness output" : "autoalign" ,
401- "clavata check for" : "clavata" ,
402- "clavata check input" : "clavata" ,
403- "clavata check output" : "clavata" ,
404- "cleanlab trustworthiness" : "cleanlab" ,
405- "content safety check input" : "content_safety" ,
406- "content safety check output" : "content_safety" ,
407- "crowdstrike aidr guard input" : "crowdstrike_aidr" ,
408- "crowdstrike aidr guard output" : "crowdstrike_aidr" ,
409- "detect pii on input" : "sensitive_data_detection" ,
410- "detect pii on output" : "sensitive_data_detection" ,
411- "detect pii on retrieval" : "sensitive_data_detection" ,
412- "detect sensitive data on input" : "sensitive_data_detection" ,
413- "detect sensitive data on output" : "sensitive_data_detection" ,
414- "detect sensitive data on retrieval" : "sensitive_data_detection" ,
415- "fiddler bot faithfulness" : "fiddler" ,
416- "fiddler bot safety" : "fiddler" ,
417- "fiddler user safety" : "fiddler" ,
418- "gliner detect pii on input" : "gliner" ,
419- "gliner detect pii on output" : "gliner" ,
420- "gliner detect pii on retrieval" : "gliner" ,
421- "gliner mask pii on input" : "gliner" ,
422- "gliner mask pii on output" : "gliner" ,
423- "gliner mask pii on retrieval" : "gliner" ,
424- "guardrailsai check input" : "guardrails_ai" ,
425- "guardrailsai check output" : "guardrails_ai" ,
426- "hallucination warning" : "hallucination" ,
427- "injection detection" : "injection_detection" ,
428- "jailbreak detection heuristics" : "jailbreak_detection" ,
429- "jailbreak detection model" : "jailbreak_detection" ,
430- "llama guard check input" : "llama_guard" ,
431- "llama guard check output" : "llama_guard" ,
432- "mask pii on input" : "sensitive_data_detection" ,
433- "mask pii on output" : "sensitive_data_detection" ,
434- "mask pii on retrieval" : "sensitive_data_detection" ,
435- "mask sensitive data on input" : "sensitive_data_detection" ,
436- "mask sensitive data on output" : "sensitive_data_detection" ,
437- "mask sensitive data on retrieval" : "sensitive_data_detection" ,
438- "pangea ai guard input" : "pangea" ,
439- "pangea ai guard output" : "pangea" ,
440- "patronus api check output" : "patronusai" ,
441- "patronus lynx check output hallucination" : "patronusai" ,
442- "policyai moderation on input" : "policyai" ,
443- "policyai moderation on output" : "policyai" ,
444- "protect prompt" : "prompt_security" ,
445- "protect response" : "prompt_security" ,
446- "regex check input" : "regex" ,
447- "regex check output" : "regex" ,
448- "regex check retrieval" : "regex" ,
449- "self check facts" : "self_check" ,
450- "self check hallucination" : "self_check" ,
451- "self check input" : "self_check" ,
452- "self check output" : "self_check" ,
453- "topic safety check input" : "topic_safety" ,
454- "trend ai guard input" : "trend_micro" ,
455- "trend ai guard output" : "trend_micro" ,
456- }
457-
458- _CONFIG_BUILTIN_FEATURE_ALIASES = {
390+ _BUILTIN_FEATURE_ID_ALIASES = {
459391 "fact_checking" : "factchecking" ,
460392 "patronus" : "patronusai" ,
393+ "privateai" : "sensitive_data_detection" ,
461394 "regex_detection" : "regex" ,
462395}
463396
397+ _BUILTIN_FLOW_FEATURE_OVERRIDES = {
398+ "self check hallucination" : "self_check" ,
399+ }
400+
464401_COLANG_V2_LIBRARY_DIR = Path (__file__ ).resolve ().parent / "colang" / "v2_x" / "library"
465402
466403
467- def _normalize_builtin_feature_id (field_name : str ) -> str :
468- """Return the documented feature id for a RailsConfigData field."""
469- return _CONFIG_BUILTIN_FEATURE_ALIASES .get (field_name , field_name )
404+ def _normalize_builtin_feature_id (feature_id : str ) -> str :
405+ """Return the stable telemetry id for a config field or manifest ."""
406+ return _BUILTIN_FEATURE_ID_ALIASES .get (feature_id , feature_id . split ( "." , 1 )[ 0 ] )
470407
471408
472409def _flow_file_name (flow : Any ) -> Optional [str ]:
@@ -509,7 +446,7 @@ def _detect_builtin_features(config: "RailsConfig") -> List[str]:
509446
510447 Uses two signals: (1) fields on ``RailsConfigData`` that differ from
511448 their defaults (explicit config), and (2) exact-match flow names
512- against a known set of built-in library flows . Only our own feature
449+ declared by the built-in rail manifest catalog . Only our own feature
513450 names are ever reported, never user-defined flow names.
514451
515452 Args:
@@ -539,6 +476,17 @@ def _detect_builtin_features(config: "RailsConfig") -> List[str]:
539476 except Exception :
540477 pass
541478
479+ try :
480+ from nemoguardrails .manifests import default_rail_catalog
481+
482+ catalog = default_rail_catalog ()
483+ except Exception :
484+ log .debug ("Failed to load the built-in rail catalog for usage telemetry" , exc_info = True )
485+ catalog = None
486+
487+ if catalog is None :
488+ return sorted (features )
489+
542490 all_flows = []
543491 for rail_group in ["input" , "output" , "retrieval" , "tool_output" , "tool_input" ]:
544492 group = getattr (rails , rail_group , None )
@@ -547,9 +495,14 @@ def _detect_builtin_features(config: "RailsConfig") -> List[str]:
547495
548496 for flow_name in all_flows :
549497 normalized = _normalize_flow_id (flow_name )
550- feature = _KNOWN_BUILTIN_FLOWS .get (normalized )
551- if feature is not None :
552- features .add (feature )
498+ manifest_name = catalog .owner_for_flow (normalized )
499+ if manifest_name is None :
500+ continue
501+ feature = _BUILTIN_FLOW_FEATURE_OVERRIDES .get (
502+ normalized ,
503+ _normalize_builtin_feature_id (manifest_name ),
504+ )
505+ features .add (feature )
553506
554507 return sorted (features )
555508
0 commit comments