Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions ppmlx/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@ def _strip_thinking(text: str) -> tuple[str, str | None]:


def _resolve_model_path(repo_id: str) -> str:
"""
Resolve a repo_id to a local path if available, otherwise return the repo_id
for direct HuggingFace loading.
"""
"""Resolve a repo_id to a local path if available, otherwise return the repo_id."""
try:
from ppmlx.models import get_model_path
local = get_model_path(repo_id)
if local:
return str(local)
from ppmlx.models import resolve_model_path
return resolve_model_path(repo_id)
except ImportError:
pass
return repo_id
return repo_id


class TextEngine:
Expand Down
9 changes: 3 additions & 6 deletions ppmlx/engine_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

def _resolve_model_path(repo_id: str) -> str:
try:
from ppmlx.models import get_model_path
local = get_model_path(repo_id)
if local:
return str(local)
from ppmlx.models import resolve_model_path
return resolve_model_path(repo_id)
except ImportError:
pass
return repo_id
return repo_id


def _l2_normalize(vec: list[float]) -> list[float]:
Expand Down
9 changes: 3 additions & 6 deletions ppmlx/engine_vlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
def _resolve_model_path(repo_id: str) -> str:
"""Resolve alias to local path if available."""
try:
from ppmlx.models import get_model_path
local = get_model_path(repo_id)
if local:
return str(local)
from ppmlx.models import resolve_model_path
return resolve_model_path(repo_id)
except ImportError:
pass
return repo_id
return repo_id


class VisionEngine:
Expand Down
9 changes: 9 additions & 0 deletions ppmlx/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,15 @@ def _bg_download() -> None:
return local_path


def resolve_model_path(repo_id: str) -> str:
"""Resolve a repo_id to a local path if available, otherwise return the
repo_id for direct HuggingFace loading."""
local = get_model_path(repo_id)
if local:
return str(local)
return repo_id


def get_model_path(alias_or_repo: str) -> Path | None:
"""Return local path if model exists, else None."""
try:
Expand Down
Loading
Loading