aigen / app /download_adapter.py
Ais
🚀 Initial commit of FastAPI LoRA chatbot
48b2ebf
raw
history blame
1.41 kB
import os
import gdown
import re
# ✅ Google Drive folder with adapter versions like 'version 1', 'version 2', etc.
DRIVE_FOLDER_URL = "https://drive.google.com/drive/folders/1S9xT92Zm9rZ4RSCxAe_DLld8vu78mqW4"
LOCAL_DEST = "adapter" # Where we'll copy the latest version
def download_latest_adapter():
print("🔽 Downloading adapter folder from Google Drive...")
# Download everything from the Drive folder into temp dir
gdown.download_folder(url=DRIVE_FOLDER_URL, output="gdrive_tmp", quiet=False, use_cookies=False)
# Find all folders named "version X"
all_versions = sorted(
[d for d in os.listdir("gdrive_tmp") if re.match(r"version \d+", d)],
key=lambda x: int(x.split()[-1])
)
if not all_versions:
raise ValueError("❌ No version folders found in Google Drive folder.")
latest = all_versions[-1]
src = os.path.join("gdrive_tmp", latest)
print(f"✅ Latest adapter found: {latest}")
# Ensure destination exists
os.makedirs(LOCAL_DEST, exist_ok=True)
# Copy files to destination
for file in os.listdir(src):
src_file = os.path.join(src, file)
dest_file = os.path.join(LOCAL_DEST, file)
os.system(f"cp '{src_file}' '{dest_file}'")
print(f"✅ Adapter copied to: {LOCAL_DEST}")
# ✅ Run automatically if script is executed directly
if __name__ == "__main__":
download_latest_adapter()