diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py index b27e1636e..1c797b5a2 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py @@ -603,17 +603,19 @@ def run_ai_cell(self, args: CellArgs, prompt: str): else: # generate output from model via provider if context: - inputs = [ - ( - f"AI: {message.content}" - if message.type == "ai" - else f"{message.type.title()}: {message.content}" - ) - for message in context + [HumanMessage(content=prompt)] - ] + inputs = "\n\n".join( + [ + ( + f"AI: {message.content}" + if message.type == "ai" + else f"{message.type.title()}: {message.content}" + ) + for message in context + [HumanMessage(content=prompt)] + ] + ) else: - inputs = [prompt] - result = provider.generate(inputs) + inputs = prompt + result = provider.generate([inputs]) output = result.generations[0][0].text