From 10543ecf86aee3cfdf3be8a3894f46ca0d90fe54 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:22:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unsloth/models/sentence_transformer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/unsloth/models/sentence_transformer.py b/unsloth/models/sentence_transformer.py index c164e2c516..85eea2bf3f 100644 --- a/unsloth/models/sentence_transformer.py +++ b/unsloth/models/sentence_transformer.py @@ -443,6 +443,7 @@ class FastSentenceTransformer(FastModel): Add Unsloth and sentence-transformers tags to the Hugging Face Hub repository. """ from huggingface_hub import HfApi + api = HfApi(token = token) if tags is None: tags = [] @@ -475,7 +476,9 @@ class FastSentenceTransformer(FastModel): # if tags exist but not right at start, use regex to append pattern = r"(^tags:\s*\n)" if re.search(pattern, content, re.MULTILINE): - content = re.sub(pattern, r"\1- unsloth\n", content, count=1, flags=re.MULTILINE) + content = re.sub( + pattern, r"\1- unsloth\n", content, count = 1, flags = re.MULTILINE + ) # add branding badge and text branding = ( @@ -485,10 +488,10 @@ class FastSentenceTransformer(FastModel): # add to description if "# SentenceTransformer" in content: - parts = content.split("# SentenceTransformer", 1) - content = parts[0] + "# SentenceTransformer" + branding + parts[1] + parts = content.split("# SentenceTransformer", 1) + content = parts[0] + "# SentenceTransformer" + branding + parts[1] else: - content += branding + content += branding with open(readme_path, "w", encoding = "utf-8") as f: f.write(content) @@ -863,7 +866,7 @@ class FastSentenceTransformer(FastModel): self[0].auto_model.save_pretrained_merged( save_directory, tokenizer = tokenizer, **kwargs ) - + # add Unsloth branding to the generated README try: FastSentenceTransformer._add_unsloth_branding(save_directory) @@ -882,8 +885,9 @@ class FastSentenceTransformer(FastModel): ) private = kwargs.get("private", None) commit_message = kwargs.get("commit_message", "Upload model") - + from huggingface_hub import HfApi + api = HfApi(token = token) try: api.create_repo( @@ -894,7 +898,7 @@ class FastSentenceTransformer(FastModel): ) except: pass - + # order doesn't seem to matter for this after repo creation... FastSentenceTransformer._add_unsloth_tags(repo_id, token)