(value: Any)
| 426 | |
| 427 | |
| 428 | def _extract_user_prompt_text(value: Any) -> str: |
| 429 | if isinstance(value, str): |
| 430 | current = _extract_current_message(value) |
| 431 | if current: |
| 432 | return current |
| 433 | cleaned = _strip_wrapper_prefix(value) |
| 434 | if cleaned: |
| 435 | return cleaned |
| 436 | return "" if _looks_like_wrapper_text(value) else value.strip() |
| 437 | if isinstance(value, list): |
| 438 | parts: list[str] = [] |
| 439 | for item in value: |
| 440 | if not isinstance(item, dict) or item.get("type") not in {"text", "input_text"}: |
| 441 | continue |
| 442 | raw = str(item.get("text", "")) |
| 443 | current = _extract_current_message(raw) |
| 444 | if current: |
| 445 | parts.append(current) |
| 446 | continue |
| 447 | cleaned = _strip_wrapper_prefix(raw) |
| 448 | if cleaned: |
| 449 | parts.append(cleaned) |
| 450 | if parts: |
| 451 | return "\n".join(parts) |
| 452 | return _content_text(value).strip() |
| 453 | |
| 454 | |
| 455 | def _extract_prompt(body: dict) -> tuple[str, str | None, int]: |
no test coverage detected