@@ -49,6 +49,7 @@ class DoctorReport:
4949 generated_at : float = 0.0
5050 core : dict [str , Any ] = field (default_factory = dict )
5151 runtime : dict [str , Any ] = field (default_factory = dict )
52+ provider_health : dict [str , Any ] = field (default_factory = dict )
5253 router : dict [str , Any ] = field (default_factory = dict )
5354 context : dict [str , Any ] = field (default_factory = dict )
5455 cognition : dict [str , Any ] = field (default_factory = dict )
@@ -62,6 +63,7 @@ def to_dict(self) -> dict[str, Any]:
6263 "generated_at" : self .generated_at ,
6364 "core" : self .core ,
6465 "runtime" : self .runtime ,
66+ "provider_health" : self .provider_health ,
6567 "router" : self .router ,
6668 "context" : self .context ,
6769 "cognition" : self .cognition ,
@@ -123,6 +125,61 @@ def _runtime_section() -> dict[str, Any]:
123125 return {"error" : f"{ type (exc ).__name__ } : { exc } " }
124126
125127
128+ def _provider_health_section () -> dict [str , Any ]:
129+ try :
130+ from dhee .cli_config import get_api_key , load_config
131+ from dhee .provider_defaults import provider_defaults
132+ except Exception as exc :
133+ return {"ok" : False , "status" : "config_error" , "error" : f"{ type (exc ).__name__ } : { exc } " }
134+
135+ config = load_config ()
136+ provider = str (config .get ("provider" ) or "nvidia" ).strip ().lower ()
137+ defaults = provider_defaults (provider )
138+ model = str (config .get ("llm_model" ) or defaults .get ("llm_model" ) or "" ).strip ()
139+ if provider != "nvidia" :
140+ return {
141+ "ok" : None ,
142+ "status" : "not_implemented" ,
143+ "provider" : provider ,
144+ "model" : model ,
145+ }
146+
147+ api_key = get_api_key (provider )
148+ if not api_key :
149+ return {
150+ "ok" : False ,
151+ "status" : "missing_api_key" ,
152+ "provider" : provider ,
153+ "model" : model ,
154+ "required_env" : defaults .get ("env_var" ),
155+ }
156+
157+ try :
158+ from dhee .llms .nvidia import NvidiaLLM
159+
160+ llm = NvidiaLLM (
161+ {
162+ "api_key" : api_key ,
163+ "model" : model ,
164+ "temperature" : 0 ,
165+ "max_tokens" : 2 ,
166+ "timeout" : 8 ,
167+ "max_retries" : 0 ,
168+ "app_retries" : 1 ,
169+ }
170+ )
171+ return llm .ping ()
172+ except Exception as exc :
173+ return {
174+ "ok" : False ,
175+ "status" : "unavailable" ,
176+ "provider" : provider ,
177+ "model" : model ,
178+ "error_type" : type (exc ).__name__ ,
179+ "error" : str (exc ),
180+ }
181+
182+
126183def _context_section () -> dict [str , Any ]:
127184 out : dict [str , Any ] = {}
128185 try :
@@ -597,6 +654,7 @@ def build_report() -> DoctorReport:
597654
598655 core = _core_section ()
599656 runtime = _runtime_section ()
657+ provider_health = _provider_health_section ()
600658 router = _router_section ()
601659 context = _context_section ()
602660 cognition = _cognition_section ()
@@ -609,6 +667,7 @@ def build_report() -> DoctorReport:
609667 generated_at = time .time (),
610668 core = core ,
611669 runtime = runtime ,
670+ provider_health = provider_health ,
612671 router = router ,
613672 context = context ,
614673 cognition = cognition ,
@@ -627,6 +686,7 @@ def format_human(report: DoctorReport) -> str:
627686 lines : list [str ] = []
628687 core = report .core
629688 runtime = report .runtime
689+ provider_health = report .provider_health
630690 router = report .router
631691 context = report .context
632692 cog = report .cognition
@@ -674,6 +734,17 @@ def format_human(report: DoctorReport) -> str:
674734 lines .append (f" runtime dir: { paths .get ('runtime_dir' )} " )
675735 lines .append ("" )
676736
737+ # Provider health
738+ lines .append ("[ provider health ]" )
739+ lines .append (f" provider: { provider_health .get ('provider' , '?' )} " )
740+ lines .append (f" model: { provider_health .get ('model' , '?' )} " )
741+ lines .append (f" status: { provider_health .get ('status' , '?' )} " )
742+ if provider_health .get ("latency_ms" ) is not None :
743+ lines .append (f" latency: { provider_health .get ('latency_ms' )} ms" )
744+ if provider_health .get ("error_type" ):
745+ lines .append (f" error: { provider_health .get ('error_type' )} : { provider_health .get ('error' )} " )
746+ lines .append ("" )
747+
677748 # Router
678749 lines .append ("[ router ]" )
679750 if "error" in router :
0 commit comments