Skip to content

Instantly share code, notes, and snippets.

@goddoe
Created November 28, 2023 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goddoe/1d87bc2d8dae6c3c2fbeb59b01c7ee87 to your computer and use it in GitHub Desktop.
Save goddoe/1d87bc2d8dae6c3c2fbeb59b01c7ee87 to your computer and use it in GitHub Desktop.
extract_code.py
def extract_code(inputs: dict) -> dict:
text = inputs["text"]
result = re.search(r'```.*?\n(.*?)\n```', text, re.DOTALL)
result = result.group(1) if result else text
return {"output": result}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment