Normalize message content — handles string and list formats.
(content: Any)
| 28 | MIN_CONFIDENCE_TO_VOTE = 0.3 |
| 29 | |
| 30 | def _normalize_content(content: Any) -> str: |
| 31 | """Normalize message content — handles string and list formats.""" |
| 32 | if isinstance(content, str): |
| 33 | return content |
| 34 | if isinstance(content, list): |
| 35 | parts = [] |
| 36 | for part in content: |
| 37 | if isinstance(part, dict) and part.get("type") == "text": |
| 38 | parts.append(part.get("text", "")) |
| 39 | elif isinstance(part, str): |
| 40 | parts.append(part) |
| 41 | return " ".join(parts) |
| 42 | return str(content) if content else "" |
| 43 | |
| 44 | |
| 45 | def _extract_last_user_message(messages: list[dict[str, Any]]) -> str: |
no test coverage detected