Share fallback field-label cleanup

This commit is contained in:
2026-06-27 01:53:06 +02:00
parent 5ab2433ca7
commit 2d3d668359
5 changed files with 47 additions and 9 deletions
+12
View File
@@ -101,6 +101,18 @@ def split_avoid(text: Any) -> tuple[str, str]:
return text[: match.start()].strip(" ."), match.group(1).strip(" .")
def strip_prompt_field_labels(
text: Any,
*,
field_labels: tuple[str, ...] | list[str] = DEFAULT_PROMPT_FIELD_LABELS,
) -> str:
text = clean_text(text)
if not text:
return ""
labels = "|".join(re.escape(name) for name in sorted(field_labels, key=len, reverse=True))
return clean_text(re.sub(rf"\b(?:{labels}):\s*", "", text))
def prompt_field(
text: Any,
label: str,