@@ -40,7 +40,7 @@ def _get_title() -> str:
4040def _get_preamble () -> str :
4141 """Get the common dependency explanation text."""
4242 return """
43-
43+
4444This document lists all available flows in the NeMo Guardrails library.
4545
4646## Understanding the tables
@@ -84,9 +84,11 @@ def _get_preamble() -> str:
8484
8585"""
8686
87+
8788CHECK = "✔"
8889CROSS = "✗"
8990
91+
9092@dataclass
9193class Flow :
9294 """Represents a Colang flow."""
@@ -100,6 +102,7 @@ class Flow:
100102 uses_llm : bool = False # Uses LLM from config.models
101103 actions : List [str ] = field (default_factory = list ) # List of actions called by this flow
102104
105+
103106class FlowAnalyzer :
104107 """Analyzes Colang flow files and categorizes flows."""
105108
@@ -133,7 +136,13 @@ class FlowAnalyzer:
133136 re .compile (r"await\s+llm\." ),
134137 ]
135138
136- def __init__ (self , library_path : Path , provider_list_path : Optional [Path ], project_root : Path , output_path : Optional [Path ] = None ):
139+ def __init__ (
140+ self ,
141+ library_path : Path ,
142+ provider_list_path : Optional [Path ],
143+ project_root : Path ,
144+ output_path : Optional [Path ] = None ,
145+ ):
137146 self .library_path = library_path
138147 self .provider_list_path = provider_list_path
139148 self .project_root = project_root
@@ -624,6 +633,7 @@ def _get_relative_path(self, target_path: str) -> str:
624633 except ValueError :
625634 # Paths don't share a common base, use os.path.relpath
626635 import os
636+
627637 return os .path .relpath (str (target ), str (output_dir ))
628638
629639 def _format_table_header (self , category_key : str , category_title : str , header_prefix : str ) -> List [str ]:
@@ -635,7 +645,9 @@ def _format_table_header(self, category_key: str, category_title: str, header_pr
635645 output .append ("" )
636646 return output
637647
638- def _format_table_asciidoc (self , category_key : str , category_title : str , flows : List [Flow ], include_links : bool = False ) -> List [str ]:
648+ def _format_table_asciidoc (
649+ self , category_key : str , category_title : str , flows : List [Flow ], include_links : bool = False
650+ ) -> List [str ]:
639651 """Format a table in AsciiDoc format."""
640652 output = self ._format_table_header (category_key , category_title , "==" )
641653 output .append ('[cols="2,1,1,1,2,6", options="header"]' )
@@ -667,19 +679,23 @@ def _format_table_asciidoc(self, category_key: str, category_title: str, flows:
667679 else :
668680 examples = "N/A"
669681
670- output .append (
671- f"| `{ flow .name } ` | { library } | { llm_usage } | { requires_external } | { desc } | { examples } "
672- )
682+ output .append (f"| `{ flow .name } ` | { library } | { llm_usage } | { requires_external } | { desc } | { examples } " )
673683
674684 output .append ("|===" )
675685 output .append ("" )
676686 return output
677687
678- def _format_table_markdown (self , category_key : str , category_title : str , flows : List [Flow ], include_links : bool = False ) -> List [str ]:
688+ def _format_table_markdown (
689+ self , category_key : str , category_title : str , flows : List [Flow ], include_links : bool = False
690+ ) -> List [str ]:
679691 """Format a table in Markdown format."""
680692 output = self ._format_table_header (category_key , category_title , "##" )
681- output .append ("| Flow Name | Library (`nemoguardrails/library/...`) | Requires a Configured LLM | Requires External Server Calls | Description | Example Configs |" )
682- output .append ("|-----------|----------------------------------------|---------------------------|--------------------------------|-------------|-----------------|" )
693+ output .append (
694+ "| Flow Name | Library (`nemoguardrails/library/...`) | Requires a Configured LLM | Requires External Server Calls | Description | Example Configs |"
695+ )
696+ output .append (
697+ "|-----------|----------------------------------------|---------------------------|--------------------------------|-------------|-----------------|"
698+ )
683699
684700 for flow in sorted (flows , key = lambda f : (f .library , f .name )):
685701 llm_usage = CHECK if flow .uses_llm else CROSS
@@ -704,9 +720,7 @@ def _format_table_markdown(self, category_key: str, category_title: str, flows:
704720 else :
705721 examples = "N/A"
706722
707- output .append (
708- f"| `{ flow .name } ` | { library } | { llm_usage } | { requires_external } | { desc } | { examples } |"
709- )
723+ output .append (f"| `{ flow .name } ` | { library } | { llm_usage } | { requires_external } | { desc } | { examples } |" )
710724
711725 output .append ("" )
712726 return output
0 commit comments