MCPcopy
hub / github.com/langroid/langroid / get_model_info

Function get_model_info

langroid/language_models/model_info.py:769–800  ·  view source on GitHub ↗

Get model information by name or enum value

(
    model: str | ModelName,
    fallback_models: List[str] = [],
)

Source from the content-addressed store, hash-verified

767
768
769def get_model_info(
770 model: str | ModelName,
771 fallback_models: List[str] = [],
772) -> ModelInfo:
773 """Get model information by name or enum value"""
774 # Sequence of models to try, starting with the primary model
775 models_to_try = [model] + fallback_models
776
777 # Find the first model in the sequence that has info defined using next()
778 # on a generator expression that filters out None results from _get_model_info
779 found_info = next(
780 (info for m in models_to_try if (info := _get_model_info(m)) is not None),
781 None, # Default value if the iterator is exhausted (no valid info found)
782 )
783
784 if found_info is not None:
785 return found_info
786
787 normalized_models = _normalize_model_names(models_to_try)
788 found_info = next(
789 (
790 info
791 for normalized_model in normalized_models
792 if (info := _get_model_info(normalized_model)) is not None
793 ),
794 None,
795 )
796 if found_info is not None:
797 return found_info
798
799 _warn_unknown_model(models_to_try)
800 return ModelInfo()
801
802
803def _get_model_info(model: str | ModelName) -> ModelInfo | None:

Calls 4

_get_model_infoFunction · 0.85
_normalize_model_namesFunction · 0.85
_warn_unknown_modelFunction · 0.85
ModelInfoClass · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…