feat(recipes): add prompt-aware duplicate detection toggle

This commit is contained in:
Will Miao
2026-08-10 00:07:14 +08:00
parent 8237e5f9ea
commit 95fb3c7fc9
20 changed files with 582 additions and 39 deletions

View File

@@ -469,6 +469,24 @@ def calculate_recipe_fingerprint(loras):
return fingerprint
def normalize_prompt_for_dedup(prompt) -> str:
"""Normalize a positive prompt for duplicate recipe matching.
Applies casefolding, collapses whitespace runs into single spaces, and
trims leading/trailing whitespace. Missing or non-string prompts
normalize to an empty string.
Args:
prompt: The positive prompt text (or None)
Returns:
str: The normalized prompt
"""
if not prompt or not isinstance(prompt, str):
return ""
return re.sub(r"\s+", " ", prompt).strip().casefold()
def calculate_relative_path_for_model(
model_data: Dict[str, Any], model_type: str = "lora"
) -> str: