jupyter-ai icon indicating copy to clipboard operation
jupyter-ai copied to clipboard

Generate command can create sections with no code cells (no retry logic)

Open JasonWeill opened this issue 2 years ago • 3 comments
trafficstars

Description

The /generate command in the chat UI can generate a notebook with no code cells, or with empty code cells where code was expected. You can see this in the sample PyTorch notebook from #90: https://github.com/jupyterlab/jupyter-ai/blob/96465d1df60a9b3be592220489f78fa59e430fd0/examples/generate/Training%20Dense%20Neural%20Network%20with%20PyTorch.ipynb

This is still possible when using Dask (see #242, #244).

Expected behavior

If code is expected, add retry logic when generating code cells.

Context

Jupyter AI version 0.9.0 (with #244 applied).

JasonWeill avatar Jul 10 '23 21:07 JasonWeill

If anyone is interested. I've generated 2 notebooks and all code cells are empty. I can see in the terminal that code was produced but the notebook just has Mardown and empty code cells.
Not an urgent issue for me at all, just thought it might be helpful for this issue. Screenshot 2023-08-30 at 17 26 13

cbonnett avatar Aug 30 '23 16:08 cbonnett

@cbonnett Thanks for reporting this issue. It seems like you are have reported this issue with 0.9.0 which is an older version. Were you able to reproduce with the latest Jupyter AI versions?

It will also be helpful to know which language model was selected for this generate command.

3coins avatar Aug 30 '23 17:08 3coins

@3coins

I think I have latest version:

pip show jupyter_ai Name: jupyter_ai Version: 2.1.0

I am using GPT-4.

Think I figured out the problem, not yet confirmed though. GPT-4 is very chatty, even if you ask it to return just code, it will often say:

Here is your code: """" code... """"

So I suspect doing some regex to catch the code from the string would fix the problem.

The problem is not there if use GPT-3.5 btw GP3.5 is less chatty compared to GPT-4.

cbonnett avatar Aug 31 '23 14:08 cbonnett