Removes enclosing code block markers ```[language] and ``` from a given string. Remarks: - The function uses a regex pattern to match code blocks that may start with ``` followed by an optional language tag (letters or numbers) and end with ```. - If a code block is detected, it re
(content: str)
| 32 | |
| 33 | |
| 34 | def remove_code_blocks(content: str) -> str: |
| 35 | """ |
| 36 | Removes enclosing code block markers ```[language] and ``` from a given string. |
| 37 | |
| 38 | Remarks: |
| 39 | - The function uses a regex pattern to match code blocks that may start with ``` followed by an optional language tag (letters or numbers) and end with ```. |
| 40 | - If a code block is detected, it returns only the inner content, stripping out the markers. |
| 41 | - If no code block markers are found, the original content is returned as-is. |
| 42 | """ |
| 43 | pattern = r"^```[a-zA-Z0-9]*\n([\s\S]*?)\n```$" |
| 44 | match = re.match(pattern, content.strip()) |
| 45 | return match.group(1).strip() if match else content.strip() |
| 46 | |
| 47 | |
| 48 | def get_image_description(image_obj, llm, vision_details): |
no test coverage detected