(content: Any)
| 559 | |
| 560 | |
| 561 | def _content_to_text(content: Any) -> str | None: |
| 562 | if content is None: |
| 563 | return None |
| 564 | if isinstance(content, str): |
| 565 | return content |
| 566 | if isinstance(content, (dict, list)): |
| 567 | try: |
| 568 | return json.dumps(content, ensure_ascii=False, separators=(",", ":")) |
| 569 | except Exception: |
| 570 | return str(content) |
| 571 | return str(content) |
| 572 | |
| 573 | |
| 574 | def _estimate_messages_tokens(messages: list[dict[str, Any]]) -> int: |
no outgoing calls
no test coverage detected