From 3aea83bfd1be31f48b9dd6a7aa73f75d0c47b220 Mon Sep 17 00:00:00 2001 From: Divyansh Choudhary Date: Thu, 19 Dec 2024 01:52:47 +0530 Subject: [PATCH] Backport PR #1155: Fix code output format in IPython --- packages/jupyter-ai-magics/jupyter_ai_magics/magics.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py index 1c797b5a2..199544f58 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py @@ -482,13 +482,7 @@ def display_output(self, output, display_format, md): lang_indicator = r"^```[a-zA-Z0-9]*\n" output = re.sub(lang_indicator, "", output) output = re.sub(r"\n```$", "", output) - new_cell_payload = dict( - source="set_next_input", - text=output, - replace=False, - ) - ip = self.shell - ip.payload_manager.write_payload(new_cell_payload) + self.shell.set_next_input(output, replace=False) return HTML( "AI generated code inserted below ⬇️", metadata=md )