MCPcopy Index your code
hub / github.com/TIGER-AI-Lab/TheoremExplainAgent / _extract_code

Function _extract_code

mllm_tools/utils.py:117–125  ·  view source on GitHub ↗

Helper to extract code block from model response, support Gemini style and OpenAI style

(text: str)

Source from the content-addressed store, hash-verified

115 return inputs
116
117def _extract_code(text: str) -> str:
118 """Helper to extract code block from model response, support Gemini style and OpenAI style"""
119 try:
120 # Find code between ```python and ``` tags
121 start = text.split("```python\n")[-1]
122 end = start.split("```")[0]
123 return end.strip()
124 except IndexError:
125 return text
126
127def _upload_to_gemini(input, mime_type=None):
128 """Uploads the given file or PIL image to Gemini.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected