2929
3030
3131def _coerce_str (value ):
32+ """Return the first string representation that litellm expects."""
3233 if isinstance (value , str ):
3334 return value
3435 if isinstance (value , list ) and value :
@@ -37,6 +38,7 @@ def _coerce_str(value):
3738
3839
3940def _first_env_value (names ):
41+ """Return the first non-empty environment variable for the provided names."""
4042 if not names :
4143 return None
4244 if isinstance (names , str ):
@@ -314,6 +316,7 @@ def astreaming(
314316
315317
316318def _register_provider_with_litellm (slug : str , config : Dict ) -> None :
319+ """Register provider metadata and custom handlers with LiteLLM."""
317320 try :
318321 from litellm .llms .openai_like .json_loader import (
319322 JSONProviderRegistry ,
@@ -379,6 +382,7 @@ def _register_provider_with_litellm(slug: str, config: Dict) -> None:
379382
380383
381384def _deep_merge (base : Dict , override : Dict ) -> Dict :
385+ """Recursively merge override dict into base without mutating inputs."""
382386 result = deepcopy (base )
383387 for key , value in override .items ():
384388 if isinstance (value , dict ) and isinstance (result .get (key ), dict ):
@@ -389,6 +393,7 @@ def _deep_merge(base: Dict, override: Dict) -> Dict:
389393
390394
391395def _load_provider_configs () -> Dict [str , Dict ]:
396+ """Load provider configuration overrides from the packaged JSON file."""
392397 configs : Dict [str , Dict ] = {}
393398 try :
394399 resource = importlib_resources .files ("aider.resources" ).joinpath (RESOURCE_FILE )
@@ -659,6 +664,7 @@ def _get_api_key(self, provider: str) -> Optional[str]:
659664
660665
661666def ensure_litellm_providers_registered () -> None :
667+ """One-time registration guard for LiteLLM provider metadata."""
662668 global _PROVIDERS_REGISTERED
663669 if _PROVIDERS_REGISTERED :
664670 return
@@ -671,6 +677,7 @@ def ensure_litellm_providers_registered() -> None:
671677
672678
673679def _cost_per_token (val : Optional [str | float | int ]) -> Optional [float ]:
680+ """Parse token pricing strings into floats, tolerating currency prefixes."""
674681 if val in (None , "" , "-" , "N/A" ):
675682 return None
676683 if val == "0" :
@@ -690,6 +697,7 @@ def _cost_per_token(val: Optional[str | float | int]) -> Optional[float]:
690697
691698
692699def _first_value (record : Dict , * keys : str ):
700+ """Return the first non-empty value for the provided keys."""
693701 for key in keys :
694702 value = record .get (key )
695703 if value not in (None , "" ):
0 commit comments