Skip to content

Commit

Permalink
fix: additional_files support glob patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
xianml committed Nov 1, 2024
1 parent e712cff commit 5d4758f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,7 @@ def from_pretrained(
Returns:
A Llama model."""
try:
from huggingface_hub import hf_hub_download, HfFileSystem
from huggingface_hub import hf_hub_download, snapshot_download, HfFileSystem
from huggingface_hub.utils import validate_repo_id
except ImportError:
raise ImportError(
Expand Down Expand Up @@ -2319,10 +2319,14 @@ def from_pretrained(
)

if len(matching_additional_files) > 1:
raise ValueError(
f"Multiple files found in {repo_id} matching {additonal_file_name}\n\n"
f"Available Files:\n{json.dumps(files)}"
snapshot_download(
repo_id=repo_id,
allow_patterns=additonal_file_name,
local_dir=local_dir,
local_dir_use_symlinks=local_dir_use_symlinks,
cache_dir=cache_dir,
)
continue

(matching_additional_file,) = matching_additional_files

Expand Down

0 comments on commit 5d4758f

Please sign in to comment.