MCPcopy Create free account
hub / github.com/1jehuang/jcode / extract_text_from_content

Function extract_text_from_content

scripts/test_soft_interrupt.py:102–117  ·  view source on GitHub ↗

Extract text from message content blocks.

(content)

Source from the content-addressed store, hash-verified

100 return ok
101
102def 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
119def print_history(history):
120 """Print conversation history for debugging."""

Calls 1

getMethod · 0.45

Tested by

no test coverage detected