| from logging_config import setup_logger | |
| logger = setup_logger(__name__) | |
| def extract_text_from_content(content): | |
| """Extract text from various message content formats.""" | |
| if isinstance(content, str): | |
| return content | |
| elif isinstance(content, list): | |
| # Handle list of text items or dictionaries | |
| text_parts = [] | |
| for item in content: | |
| if isinstance(item, dict): | |
| # Extract text from dictionary format | |
| if 'text' in item: | |
| text_parts.append(item['text']) | |
| elif isinstance(item, str): | |
| text_parts.append(item) | |
| return ''.join(text_parts) | |
| else: | |
| # Fallback for any other format | |
| return str(content) | |