Akshanshsensei/PDF-Constrained-Conversational-Agent
1
1import os2from huggingface_hub import HfApi3 4def upload_app():5 print("=== Hugging Face Full Sync Uploader ===")6 token = input("Please paste your Hugging Face Access Token (with Write permission): ").strip()7 8 if not token:9 print("Error: Token cannot be empty.")10 return11 12 api = HfApi(token=token)13 repo_id = "Akshanshsensei/PDF-Constrained-Conversational-Agent"14 repo_type = "space"15 16 # All files that need to be kept in sync with the Space17 files_to_upload = [18 "app.py",19 "requirements.txt",20 "README.md",21 "config.py",22 ]23 24 print(f"\nUploading {len(files_to_upload)} files to Hugging Face Space...")25 success_count = 026 for file_path in files_to_upload:27 if not os.path.exists(file_path):28 print(f" ⚠️ Skipping {file_path} (not found locally)")29 continue30 try:31 api.upload_file(32 path_or_fileobj=file_path,33 path_in_repo=file_path,34 repo_id=repo_id,35 repo_type=repo_type,36 commit_message=f"Sync {file_path}"37 )38 print(f" ✅ {file_path} uploaded.")39 success_count += 140 except Exception as e:41 print(f" ❌ Error uploading {file_path}: {e}")42 43 if success_count > 0:44 print(f"\n✅ Done! {success_count}/{len(files_to_upload)} files uploaded.")45 print("Your Space is now rebuilding with the latest changes!")46 else:47 print("\n❌ No files were uploaded. Check your token and try again.")48 49if __name__ == "__main__":50 upload_app()51 