CoolFace
Apppublic

Akshanshsensei/PDF-Constrained-Conversational-Agent

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
fix_hf_space.py55 linesDownload Raw Back to root
1import os2from huggingface_hub import HfApi3 4def fix_huggingface_space():5    print("=== Hugging Face Space Fixer ===")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    files_to_delete = [17        "bm25_retriever.py", "chunker.py", "embedder.py", 18        "generator.py", "hybrid_retriever.py", "logger.py", 19        "memory.py", "parser.py", "reranker.py"20    ]21 22    print(f"\nConnecting to {repo_id}...")23    24    # 1. Delete the bad files25    for file_path in files_to_delete:26        try:27            print(f"Deleting {file_path} from the root directory...")28            api.delete_file(path_in_repo=file_path, repo_id=repo_id, repo_type=repo_type, commit_message=f"Delete misplaced {file_path}")29        except Exception as e:30            print(f"  (Skipped {file_path} - it might already be deleted or not exist)")31 32    print("\nโœ… Bad files deleted successfully!")33    34    # 2. Upload the correct folders35    folders_to_upload = ["agent", "core", "utils"]36    37    for folder in folders_to_upload:38        if os.path.exists(folder):39            print(f"\nUploading correct {folder}/ folder...")40            api.upload_folder(41                folder_path=folder,42                path_in_repo=folder,43                repo_id=repo_id,44                repo_type=repo_type,45                commit_message=f"Upload correct {folder} folder"46            )47        else:48            print(f"Warning: Could not find local folder {folder}/")49 50    print("\n๐ŸŽ‰ All done! Your Hugging Face space should now build successfully.")51    print("Go check your space: https://huggingface.co/spaces/Akshanshsensei/PDF-Constrained-Conversational-Agent")52 53if __name__ == "__main__":54    fix_huggingface_space()55