1616from mindee .v2 .commands .extraction_command import ExtractionCommand
1717from mindee .v2 .commands .ocr_command import OcrCommand
1818from mindee .v2 .commands .search_models_command import SearchModelsCommand
19+ from mindee .v2 .commands .search_rag_documents_command import SearchRagDocumentsCommand
1920from mindee .v2 .commands .split_command import SplitCommand
2021from mindee .v2 .error .mindee_api_v2_error import MindeeAPIV2Error
2122
@@ -51,7 +52,7 @@ class MindeeParser:
5152
5253 * V2 inference commands are exposed at the root level
5354 (``classification``, ``crop``, ``extraction``, ``ocr``, ``split``).
54- * The ``search-models`` utility is also at the root.
55+ * The ``search-models`` and ``search-rag-docs`` utilities are also at the root.
5556 * V1 product commands are wrapped under a ``v1`` subcommand.
5657 """
5758
@@ -60,6 +61,7 @@ class MindeeParser:
6061 _client_factory : Callable [[str | None ], Client ]
6162 _inference_commands : dict [str , BaseInferenceCommand ]
6263 _search_models_command : SearchModelsCommand
64+ _search_rag_documents_command : SearchRagDocumentsCommand
6365
6466 def __init__ (
6567 self ,
@@ -76,6 +78,7 @@ def __init__(
7678 cmd .name : cmd for cmd in _build_inference_commands ()
7779 }
7880 self ._search_models_command = SearchModelsCommand ()
81+ self ._search_rag_documents_command = SearchRagDocumentsCommand ()
7982 if parsed_args is None :
8083 self ._build_parser ()
8184 self .parsed_args = self .parser .parse_args ()
@@ -95,27 +98,33 @@ def call_parse(self) -> int:
9598 self .parser .print_help ()
9699 return 1
97100 try :
98- if cmd == "v1" :
99- v1_parser = V1MindeeParser (parsed_args = self .parsed_args )
100- v1_parser .call_parse ()
101- return 0
102- if cmd == self ._search_models_command .name :
103- return self ._search_models_command .execute (
104- self .parsed_args , self ._client_factory
105- )
106- inference_command = self ._inference_commands .get (cmd )
107- if inference_command is None :
108- raise ValueError (f"Unknown command: { cmd } " )
109- return inference_command .execute (self .parsed_args , self ._client_factory )
101+ return self ._execute_command (cmd )
110102 except MindeeAPIV2Error as exc :
111103 return _report_api_key_error (exc , "V2" , "MINDEE_V2_API_KEY" )
112104 except MindeeAPIError as exc :
113105 return _report_api_key_error (exc , "V1" , "MINDEE_API_KEY" )
114106
107+ def _execute_command (self , cmd : str ) -> int :
108+ """Execute a parsed subcommand."""
109+ if cmd == "v1" :
110+ v1_parser = V1MindeeParser (parsed_args = self .parsed_args )
111+ v1_parser .call_parse ()
112+ return 0
113+ if cmd == self ._search_models_command .name :
114+ return self ._search_models_command .execute (
115+ self .parsed_args , self ._client_factory
116+ )
117+ if cmd == self ._search_rag_documents_command .name :
118+ return self ._search_rag_documents_command .execute (
119+ self .parsed_args , self ._client_factory
120+ )
121+
122+ inference_command = self ._inference_commands .get (cmd )
123+ if inference_command is None :
124+ raise ValueError (f"Unknown command: { cmd } " )
125+ return inference_command .execute (self .parsed_args , self ._client_factory )
126+
115127 def _build_parser (self ) -> None :
116- # ``--verbose`` / ``-v`` are pre-consumed in ``mindee.cli.main``
117- # (mirroring the .NET ``args.Contains("--verbose")`` pattern); we
118- # still register them here for ``--help`` discoverability.
119128 self .parser .add_argument (
120129 "-v" ,
121130 "--verbose" ,
@@ -129,6 +138,7 @@ def _build_parser(self) -> None:
129138 cmd .register (subparsers )
130139
131140 self ._search_models_command .register (subparsers )
141+ self ._search_rag_documents_command .register (subparsers )
132142
133143 v1_parser = subparsers .add_parser (
134144 "v1" ,
0 commit comments