Anvesh-Agent-V1-0 / utils.py
developeranveshraman's picture
Upload 14 files
86e8460 verified
raw
history blame contribute delete
433 Bytes
def clean_markdown_code(text: str) -> str:
"""Removes markdown code blocks from LLM output."""
lines = text.split("\n")
if not lines:
return text
# Remove starting ```python or similar
if lines[0].strip().startswith("```"):
lines = lines[1:]
# Remove ending ```
if lines and lines[-1].strip() == "```":
lines = lines[:-1]
return "\n".join(lines).strip()