MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _extract_code

Method _extract_code

runtime/node/executor/python_executor.py:95–103  ·  view source on GitHub ↗
(self, message: Message | None)

Source from the content-addressed store, hash-verified

93 return root
94
95 def _extract_code(self, message: Message | None) -> str:
96 if not message:
97 return ""
98 raw = message.text_content()
99 if not raw or not raw.strip():
100 return ""
101 match = _CODE_BLOCK_RE.search(raw)
102 code = match.group("code") if match else raw
103 return textwrap.dedent(code).strip()
104
105 def _write_script_file(self, node: Node, workspace: Path, code: str) -> Path:
106 counters = self.context.global_state.setdefault(self.COUNTER_KEY, {})

Callers 1

executeMethod · 0.95

Calls 1

text_contentMethod · 0.80

Tested by

no test coverage detected