INNER CODE UNIT · Python
_clear_mlx_cache
cubist38/mlx-openai-server · app/server.py:71
def _clear_mlx_cache() -> None:
"""Clear MLX cache without importing MLX into processes that do not use it."""
mx = sys.modules.get("mlx.core")
if mx is None:
return
mx.clear_cache()
def _attach_sampling_defaults(handler: Any, config: Any) -> Any:
"""Attach configured sampling-default attributes to a handler or proxy."""
for field_name in _SAMPLING_DEFAULT_FIELDS:
setattr(handler, field_name, getattr(config, field_name, None))
setattr(handler, "_uses_model_sampling_defaults", True)
return handler