File size: 879 Bytes
cca4857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import logging
import os

from huggingface_hub import hf_hub_download, snapshot_download

from app._config import settings
from app.paths import models_cache_path, models_path

os.makedirs(models_path, exist_ok=True)

logger = logging.getLogger(__name__)

# Download embedding model
embedding_path = models_path / "embedding"
logger.info(f"Downloading embedding: {settings.LOCAL_HF_EMBEDDING_MODEL_NAME}")
snapshot_download(
    repo_id=settings.LOCAL_HF_EMBEDDING_MODEL_NAME,
    cache_dir=models_cache_path,
    local_dir=embedding_path,
)
logger.info("Embedding model downloaded")

# Download LLM model
logger.info(f"Downloading LLM: {settings.LOCAL_HF_LLM_MODEL_FILE}")
hf_hub_download(
    repo_id=settings.LOCAL_HF_LLM_REPO_ID,
    filename=settings.LOCAL_HF_LLM_MODEL_FILE,
    cache_dir=models_cache_path,
    local_dir=models_path,
)
logger.info("LLM model downloaded")