Spaces:
Sleeping
Sleeping
| 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() |