"""Upload the foodhub_project folder to the Hugging Face Space nsriram78/FoodHubChatbot.""" import os from dotenv import load_dotenv from huggingface_hub import HfApi from huggingface_hub.utils import RepositoryNotFoundError load_dotenv() HF_TOKEN = os.getenv("HF_TOKEN") REPO_ID = "nsriram78/FoodHubChatbot" REPO_TYPE = "space" api = HfApi(token=HF_TOKEN) # Verify the Space exists before uploading try: api.repo_info(repo_id=REPO_ID, repo_type=REPO_TYPE) print(f"Space '{REPO_ID}' found. Uploading files...") except RepositoryNotFoundError: print(f"Space '{REPO_ID}' not found. Please create it on Hugging Face first.") raise # Upload the entire foodhub_project folder as the Space contents api.upload_folder( folder_path=os.path.dirname(os.path.abspath(__file__)), repo_id=REPO_ID, repo_type=REPO_TYPE, path_in_repo="", ) print(f"Upload complete. Visit: https://huggingface.co/spaces/{REPO_ID}")