File size: 2,239 Bytes
547e622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import sys
import shutil
import argparse

def copy_model(source_path, destination_dir):
    """Copier le modèle GGUF depuis le répertoire source vers le répertoire destination"""
    try:
        # Vérifier si le fichier source existe
        if not os.path.exists(source_path):
            print(f"Erreur: Le fichier source '{source_path}' n'existe pas.")
            return False
        
        # Créer le répertoire de destination s'il n'existe pas
        if not os.path.exists(destination_dir):
            os.makedirs(destination_dir)
        
        # Construire le chemin complet de destination
        destination_path = os.path.join(destination_dir, os.path.basename(source_path))
        
        # Copier le fichier
        print(f"Copie du modèle de {source_path} vers {destination_path}...")
        shutil.copy2(source_path, destination_path)
        
        print(f"Le modèle a été copié avec succès vers {destination_path}")
        return True
    
    except Exception as e:
        print(f"Erreur lors de la copie du modèle: {str(e)}")
        return False

def main():
    parser = argparse.ArgumentParser(description="Copie un modèle GGUF depuis un répertoire source")
    parser.add_argument("--source", default="../models/Mistral-7B-Instruct-v0.3.Q4_K_M.gguf", 
                        help="Chemin vers le fichier du modèle source")
    parser.add_argument("--dest", default="./models", 
                        help="Répertoire de destination pour le modèle")
    
    args = parser.parse_args()
    
    # Obtenir les chemins absolus
    # Obtenir le chemin absolu du répertoire courant
    current_dir = os.path.dirname(os.path.abspath(__file__))
    # Construire le chemin source absolu
    source_path = os.path.abspath(os.path.join(current_dir, "..", "models", "Mistral-7B-Instruct-v0.3.Q4_K_M.gguf"))
    destination_dir = os.path.join(current_dir, "models")
    
    print(f"Recherche du modèle à: {source_path}")
    
    # Copier le modèle
    success = copy_model(source_path, destination_dir)
    
    # Terminer avec le code approprié
    sys.exit(0 if success else 1)

if __name__ == "__main__":
    main()