fix: produce card for local models with existing readme (#157)
This commit is contained in:
+15
-3
@@ -823,11 +823,23 @@ def run():
|
||||
token=token,
|
||||
)
|
||||
|
||||
# If the model path doesn't exist locally, it can be assumed
|
||||
# to be a model hosted on the Hugging Face Hub, in which case
|
||||
# If the model path exists locally and includes the
|
||||
# card, use it directly. If the model path doesn't
|
||||
# exist locally, it can be assumed to be a model
|
||||
# hosted on the Hugging Face Hub, in which case
|
||||
# we can retrieve the model card.
|
||||
if not Path(settings.model).exists():
|
||||
model_path = Path(settings.model)
|
||||
if model_path.exists():
|
||||
card_path = (
|
||||
model_path / huggingface_hub.constants.REPOCARD_NAME
|
||||
)
|
||||
if card_path.exists():
|
||||
card = ModelCard.load(card_path)
|
||||
else:
|
||||
card = None
|
||||
else:
|
||||
card = ModelCard.load(settings.model)
|
||||
if card is not None:
|
||||
if card.data is None:
|
||||
card.data = ModelCardData()
|
||||
if card.data.tags is None:
|
||||
|
||||
@@ -271,6 +271,10 @@ def get_readme_intro(
|
||||
base_refusals: int,
|
||||
bad_prompts: list[Prompt],
|
||||
) -> str:
|
||||
if Path(settings.model).exists():
|
||||
# Hide the path, which may contain private information.
|
||||
model_link = "a model"
|
||||
else:
|
||||
model_link = f"[{settings.model}](https://huggingface.co/{settings.model})"
|
||||
|
||||
return f"""# This is a decensored version of {
|
||||
|
||||
Reference in New Issue
Block a user