File size: 1,108 Bytes
4225666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Script to download required ML models.
"""
from app.core.config import settings
from pathlib import Path
import requests
from tqdm import tqdm

def download_file(url: str, destination: Path):
    response = requests.get(url, stream=True)
    total_size = int(response.headers.get('content-length', 0))
    
    with open(destination, 'wb') as file, tqdm(
        total=total_size,
        unit='B',
        unit_scale=True
    ) as pbar:
        for chunk in response.iter_content(chunk_size=8192):
            file.write(chunk)
            pbar.update(len(chunk))

def main():
    model_dir = settings.model_path
    model_dir.mkdir(parents=True, exist_ok=True)
    
    # Add your model download URL
    model_url = "https://huggingface.co/.../Qwen2.5-0.5B-Instruct-Q4_K_M.gguf"
    model_path = model_dir / settings.qwen_model_file
    
    if model_path.exists():
        print(f"Model already exists: {model_path}")
        return
    
    print(f"Downloading model to {model_path}...")
    download_file(model_url, model_path)
    print("Download complete!")

if __name__ == "__main__":
    main()