diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py index 55874a84e..9fb891682 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py @@ -1,5 +1,5 @@ -import os import json +import os import warnings from typing import Optional @@ -189,6 +189,8 @@ def ai(self, line, cell=None): # if the user wants code, add another cell with the output. if args.format == 'code': + # Strip leading and trailing triple-backticks + output = output.removeprefix('```\n').removesuffix('\n```') new_cell_payload = dict( source='set_next_input', text=output,