File size: 818 Bytes
60fc5e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from huggingface_hub import HfApi
import os

api = HfApi()
space_id = "Kurian07/Ultimate_llm_rag"  
folder_path = "C:/Users/kuria/OneDrive/Desktop/llm/chatPDF-RAG/embeddingModel"

for root, _, files in os.walk(folder_path):
    for file in files:
        file_path = os.path.join(root, file)
        relative_path = os.path.relpath(file_path, folder_path)  # Path inside the repo

        try:
            # Attempt to upload each file
            api.upload_file(
                path_or_fileobj=file_path,
                path_in_repo=relative_path,
                repo_id=space_id,
                repo_type="space"
            )
            print(f"Uploaded {relative_path} to Hugging Face Space.")
        except Exception as e:
            print(f"Failed to upload {relative_path}: {e}")