Spaces:
Sleeping
Sleeping
File size: 1,142 Bytes
edb94bf |
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 |
from huggingface_hub import HfApi, create_repo
import os
import shutil
def upload_to_hub():
# Initialize the Hugging Face API
api = HfApi()
# Your Hugging Face info
repo_id = "harithapliyal/osho-vector-db"
# Create the dataset repository if it doesn't exist
try:
print("Creating dataset repository...")
create_repo(
repo_id=repo_id,
repo_type="dataset",
private=False
)
print("Dataset repository created successfully!")
except Exception as e:
print(f"Note: {str(e)}")
# Local vector database path
local_db_path = os.path.join(os.getcwd(), "vector_db")
print(f"Uploading vector database from {local_db_path}")
try:
# Upload the entire directory
api.upload_folder(
folder_path=local_db_path,
repo_id=repo_id,
repo_type="dataset"
)
print("Successfully uploaded vector database to Hugging Face!")
except Exception as e:
print(f"Error uploading to Hugging Face: {str(e)}")
if __name__ == "__main__":
upload_to_hub()
|