Best-effort string representation of the content.
(self)
| 273 | ) |
| 274 | |
| 275 | def text_content(self) -> str: |
| 276 | """Best-effort string representation of the content.""" |
| 277 | if self.content is None: |
| 278 | return "" |
| 279 | if isinstance(self.content, str): |
| 280 | return self.content |
| 281 | # Some providers (e.g., multimodal) return list content; join textual parts. |
| 282 | parts = [] |
| 283 | for block in self.blocks(): |
| 284 | description = block.describe() |
| 285 | if description: |
| 286 | parts.append(description) |
| 287 | return "\n".join(parts) |
| 288 | |
| 289 | def blocks(self) -> List[MessageBlock]: |
| 290 | """Return content as a list of MessageBlock items.""" |
no test coverage detected