MCPcopy Index your code
hub / github.com/caesarHQ/textSQL / extract_code_from_markdown

Function extract_code_from_markdown

byod/api/app/utils.py:87–98  ·  view source on GitHub ↗
(assistant_message_content)

Source from the content-addressed store, hash-verified

85
86
87def extract_code_from_markdown(assistant_message_content):
88 matches = re.findall(r"```([\s\S]+?)```", assistant_message_content)
89
90 if matches:
91 code_str = matches[0]
92 match = re.search(r"(?i)sql\s+(.*)", code_str, re.DOTALL)
93 if match:
94 code_str = match.group(1)
95 else:
96 code_str = assistant_message_content
97
98 return code_str

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected