Extract text from message content blocks.
(content)
| 100 | return ok |
| 101 | |
| 102 | def extract_text_from_content(content): |
| 103 | """Extract text from message content blocks.""" |
| 104 | if isinstance(content, str): |
| 105 | return content |
| 106 | if isinstance(content, list): |
| 107 | texts = [] |
| 108 | for block in content: |
| 109 | if isinstance(block, dict): |
| 110 | if block.get('type') == 'text': |
| 111 | texts.append(block.get('text', '')) |
| 112 | elif 'text' in block: |
| 113 | texts.append(block['text']) |
| 114 | elif isinstance(block, str): |
| 115 | texts.append(block) |
| 116 | return ' '.join(texts) |
| 117 | return str(content) |
| 118 | |
| 119 | def print_history(history): |
| 120 | """Print conversation history for debugging.""" |
no test coverage detected