Helper to extract code block from model response, support Gemini style and OpenAI style
(text: str)
| 115 | return inputs |
| 116 | |
| 117 | def _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 | |
| 127 | def _upload_to_gemini(input, mime_type=None): |
| 128 | """Uploads the given file or PIL image to Gemini. |
nothing calls this directly
no outgoing calls
no test coverage detected