MCPcopy
hub / github.com/jundot/omlx / list_models

Function list_models

omlx/admin/routes.py:1779–1902  ·  view source on GitHub ↗

List all models with their settings. Returns model information from the engine pool combined with per-model settings from the settings manager. Returns: JSON list of models with their status and settings. Raises: HTTPException: 401 if not authenticated, 503 if

(is_admin: bool = Depends(require_admin))

Source from the content-addressed store, hash-verified

1777
1778@router.get("/api/models")
1779async def list_models(is_admin: bool = Depends(require_admin)):
1780 """
1781 List all models with their settings.
1782
1783 Returns model information from the engine pool combined with
1784 per-model settings from the settings manager.
1785
1786 Returns:
1787 JSON list of models with their status and settings.
1788
1789 Raises:
1790 HTTPException: 401 if not authenticated, 503 if server not initialized.
1791 """
1792 engine_pool = _get_engine_pool()
1793 settings_manager = _get_settings_manager()
1794 server_state = _get_server_state()
1795
1796 if engine_pool is None:
1797 raise HTTPException(status_code=503, detail="Server not initialized")
1798
1799 # Get engine pool status
1800 status = engine_pool.get_status()
1801 models_status = status.get("models", [])
1802
1803 # Get all model settings
1804 all_settings = settings_manager.get_all_settings() if settings_manager else {}
1805
1806 # SSD cache dir is set on the scheduler_config when the user enables paged
1807 # SSD caching; admin UI consumes it to gate the dflash SSD toggle.
1808 ssd_cache_dir = getattr(
1809 getattr(engine_pool, "_scheduler_config", None),
1810 "paged_ssd_cache_dir",
1811 None,
1812 )
1813 dflash_ssd_cache_available = bool(ssd_cache_dir)
1814
1815 # Combine model info with settings
1816 models = []
1817 for model_info in models_status:
1818 model_id = model_info["id"]
1819 settings = all_settings.get(model_id)
1820
1821 is_paroquant, paroquant_reason = _paroquant_compat_for_model(model_info)
1822 compat_ok, compat_reason = _dflash_compat_for_model(model_info)
1823 mtp_compat_ok, mtp_compat_reason = _mtp_compat_for_model(model_info)
1824
1825 model_data = {
1826 "id": model_id,
1827 "model_path": model_info.get("model_path", ""),
1828 "loaded": model_info.get("loaded", False),
1829 "is_loading": model_info.get("is_loading", False),
1830 "estimated_size": model_info.get("estimated_size", 0),
1831 "estimated_size_formatted": format_size(
1832 model_info.get("estimated_size", 0)
1833 ),
1834 "actual_size": model_info.get("actual_size") or 0,
1835 "actual_size_formatted": (
1836 format_size(model_info.get("actual_size", 0))

Callers

nothing calls this directly

Calls 11

_get_engine_poolFunction · 0.85
_get_settings_managerFunction · 0.85
_dflash_compat_for_modelFunction · 0.85
_mtp_compat_for_modelFunction · 0.85
markitdown_model_visibleFunction · 0.85
get_all_settingsMethod · 0.80
appendMethod · 0.80
format_sizeFunction · 0.70
get_statusMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected