Fix web API framework detection for non-mlx-community models (#42)

The /v1/models endpoint was not reading README front-matter when
detecting model frameworks, causing models from organizations like
lmstudio-community to be filtered out even when properly tagged as MLX.

This completes the implementation started in #31 by ensuring the web
API uses the same front-matter detection as the CLI.

- Import read_front_matter from operations.common
- Read front-matter before calling detect_framework()
- Pass fm parameter to align with CLI behavior

Fixes #41

Signed-off-by: Robert Clark <robert.clark@niftybean.com>
This commit is contained in:
limey
2025-11-16 08:01:48 +13:00
committed by GitHub
parent 21cf188fcc
commit f88c1a273b
+7 -3
View File
@@ -583,7 +583,7 @@ async def health_check():
async def list_models():
"""List available MLX models in the cache."""
from .cache import cache_dir_to_hf
from ..operations.common import detect_framework
from ..operations.common import detect_framework, read_front_matter
from ..operations.health import is_model_healthy
model_list = []
@@ -604,8 +604,12 @@ async def list_models():
snapshots = [d for d in snapshots_dir.iterdir() if d.is_dir()]
if snapshots:
selected_path = snapshots[0]
if detect_framework(model_name, model_dir, selected_path) == "MLX" and is_model_healthy(model_name)[0]:
# Read front-matter for framework detection (align with CLI behavior)
probe = selected_path if selected_path is not None else model_dir
fm = read_front_matter(probe)
if detect_framework(model_name, model_dir, selected_path, fm) == "MLX" and is_model_healthy(model_name)[0]:
# Get model context length (best effort)
context_length = None
try: