Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create /autonotebook command for AI generated notebooks #90

Merged
merged 8 commits into from
Apr 20, 2023

Conversation

ellisonbg
Copy link
Contributor

This PR implements an /autonotebook command that enables a user to provide a description of a notebook. Jupyter AI will then create the notebook and save it to disk. This uses a combination of different LangChain chains that are wired together to create the notebook in steps (outline of sections, code for each section, title, summary, improve code, etc.).

Here is an example of its output:

Screen Shot 2023-04-18 at 11 20 58 AM

packages/jupyter-ai/jupyter_ai/actors/autonotebook.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors/autonotebook.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors/autonotebook.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors/autonotebook.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors/autonotebook.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors/autonotebook.py Outdated Show resolved Hide resolved
outline = generate_code(outline, llm=self.llm, verbose=True)
outline = generate_title_and_summary(outline, llm=self.llm)
notebook = create_notebook(outline)
final_path = os.path.join(self.root_dir, outline['title'] + '.ipynb')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a separate variable for the filename, so that we can strip out unsuitable characters like / or & (on Windows), and so that we can replace spaces with - or _?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's do this in a follow up PR.

@dlqqq
Copy link
Member

dlqqq commented Apr 19, 2023

This looks great! I think the strategy of having the backend decompose a complex task (in this case, generating a notebook) by defining multiple chains is a great idea; this will help less frequently correct models behave as expected. Two points I wanted to call out here:

  1. I believe users will want a unified command interface for generation tasks, e.g. /generate notebook instead of /autonotebook. This command should also support the output formats that we support in magics, e.g. /generate (notebook | math | json | ...). The implementation should also leverage LangChain output parsers to provide a stronger guarantee of validity.
  • I think for most of these output formats, we would default to rendering it in the chat UI rather than creating a new file, but for some output formats like JSON, we could have a separate json-file argument that allows users to persist the generated JSON into a file.
  1. Given Brian's availability, I think it's best not to block this PR over enhancements that can be implemented later as follow-up items.

@ellisonbg ellisonbg merged commit 629909a into jupyterlab:main Apr 20, 2023
dbelgrod pushed a commit to dbelgrod/jupyter-ai that referenced this pull request Jun 10, 2024
* Initial autonotebook work.

* Working autonotebook.

* Adding first autogenerated notebook example.

* Removing file.

* Adding second autonotebook example.

* Cleaning up code, renaming autonotebook to generate.

* Minor fixes, adding new example notebook.

* Renaming examples subdir.
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
* Initial autonotebook work.

* Working autonotebook.

* Adding first autogenerated notebook example.

* Removing file.

* Adding second autonotebook example.

* Cleaning up code, renaming autonotebook to generate.

* Minor fixes, adding new example notebook.

* Renaming examples subdir.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request @jupyter-ai/chatui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants