Remove optional model thinking markup from user-facing text.
(text: str)
| 362 | |
| 363 | |
| 364 | def _visible_text(text: str) -> str: |
| 365 | """Remove optional model thinking markup from user-facing text.""" |
| 366 | text = _THINK_BLOCK_RE.sub("", text) |
| 367 | if "</think>" in text.lower() and "<think>" not in text.lower(): |
| 368 | text = re.split(r"</think>", text, flags=re.IGNORECASE)[-1] |
| 369 | return re.sub(r"</?think>", "", text, flags=re.IGNORECASE).strip() |
| 370 | |
| 371 | |
| 372 | def _is_answer_text(part_type: str, part: dict[str, Any]) -> bool: |
no outgoing calls
no test coverage detected