Spaces:
Sleeping
Sleeping
| """ | |
| Télécharger le modèle DeepSeek-Coder au format GGUF | |
| """ | |
| import os | |
| try: | |
| from huggingface_hub import hf_hub_download | |
| HF_AVAILABLE = True | |
| except ImportError: | |
| HF_AVAILABLE = False | |
| print("❌ huggingface-hub n'est pas installé") | |
| # Configuration | |
| MODEL_REPO = "bartowski/DeepSeek-Coder-1.3B-Instruct-GGUF" | |
| MODEL_FILE = "DeepSeek-Coder-1.3B-Instruct-Q4_K_M.gguf" | |
| LOCAL_PATH = "./models" | |
| def download_model(): | |
| """Télécharger le modèle GGUF""" | |
| if not HF_AVAILABLE: | |
| print("❌ Impossible de télécharger: huggingface-hub non disponible") | |
| return None | |
| os.makedirs(LOCAL_PATH, exist_ok=True) | |
| print(f"📥 Téléchargement de {MODEL_FILE}...") | |
| try: | |
| model_path = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=MODEL_FILE, | |
| local_dir=LOCAL_PATH, | |
| local_dir_use_symlinks=False, | |
| resume_download=True | |
| ) | |
| print(f"✅ Modèle téléchargé: {model_path}") | |
| print(f"📊 Taille: {os.path.getsize(model_path) / 1024 / 1024:.2f} MB") | |
| return model_path | |
| except Exception as e: | |
| print(f"❌ Erreur: {e}") | |
| # Fallback: télécharger un modèle plus petit | |
| print("🔄 Téléchargement d'un modèle plus petit...") | |
| try: | |
| model_path = hf_hub_download( | |
| repo_id="TheBloke/DeepSeek-Coder-1.3B-Instruct-GGUF", | |
| filename="deepseek-coder-1.3b-instruct.Q2_K.gguf", | |
| local_dir=LOCAL_PATH, | |
| local_dir_use_symlinks=False | |
| ) | |
| print(f"✅ Modèle de secours téléchargé") | |
| return model_path | |
| except Exception as e2: | |
| print(f"❌ Impossible de télécharger aucun modèle: {e2}") | |
| return None | |
| if __name__ == "__main__": | |
| download_model() |