Commit fe7a30dc authored by Your Name's avatar Your Name

Simplify --download-model: use cache module directly

- Remove auto-detection logic, just use download_model from cache
- User can specify --download-file-pattern for non-GGUF models
parent 01bdfe14
...@@ -104,39 +104,11 @@ def main(): ...@@ -104,39 +104,11 @@ def main():
if args.download_model: if args.download_model:
print(f"\n=== Downloading Model: {args.download_model} ===") print(f"\n=== Downloading Model: {args.download_model} ===")
from codai.models.cache import download_model, is_huggingface_model_id from codai.models.cache import download_model
from huggingface_hub import list_repo_files
# Use provided file pattern or default to .gguf
# Determine file pattern for HF downloads file_pattern = args.download_file_pattern if args.download_file_pattern else '.gguf'
file_pattern = args.download_file_pattern if args.download_file_pattern:
if file_pattern is None:
model_id = args.download_model
if is_huggingface_model_id(model_id):
# It's a HuggingFace model ID - try to detect available files
print("Scanning HuggingFace repo for available files...")
try:
files = list(list_repo_files(model_id))
print(f"Found {len(files)} files in repo")
# Try common patterns in order of preference
patterns = ['.gguf', '.safetensors', '.bin', '.pt', '.pth']
for pattern in patterns:
matching = [f for f in files if f.endswith(pattern)]
if matching:
file_pattern = pattern
print(f"Auto-detected file pattern: {file_pattern} (found {len(matching)} file(s))")
break
if not file_pattern:
print("Warning: Could not auto-detect file pattern, using .gguf")
file_pattern = '.gguf'
except Exception as e:
print(f"Warning: Could not list repo files: {e}")
file_pattern = '.gguf'
else:
# URL or local - no pattern needed
file_pattern = ''
else:
print(f"File pattern: {file_pattern}") print(f"File pattern: {file_pattern}")
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment