Skip to content

Commit

Permalink
Support Notebook 7 (#827)
Browse files Browse the repository at this point in the history
* Support Notebook 7

* Mention Notebook 7 in the docs

* fix IStatusBar requirement

* Update docs/source/users/index.md

Co-authored-by: david qiu <[email protected]>

* move notebook 7 note in the docs

---------

Co-authored-by: david qiu <[email protected]>
  • Loading branch information
jtpio and dlqqq authored Jun 17, 2024
1 parent f875fef commit ff022fe
Show file tree
Hide file tree
Showing 8 changed files with 585 additions and 821 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Documentation is available on [ReadTheDocs](https://jupyter-ai.readthedocs.io/en
You will need to have installed the following software to use Jupyter AI:

- Python 3.8 - 3.11
- JupyterLab 4
- JupyterLab 4 or Notebook 7

In addition, you will need access to at least one model provider.

Expand Down
17 changes: 17 additions & 0 deletions docs/source/users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ conda config --set channel_priority strict
conda install jupyterlab~=4.0
```

You can also use Jupyter AI in Jupyter Notebook 7.2+. To install Jupyter Notebook 7.2:

1. via `pip`:

```
pip install notebook~=7.2
```

2. via `conda`:
```
conda install notebook~=7.2
```

:::{note}
To activate the chat interface in Jupyter Notebook, click on "View > Left sidebar > Show Jupyter AI Chat".
:::

The `jupyter_ai_magics` package, which provides exclusively the IPython magics,
does not depend on JupyterLab or `jupyter_ai`. You can install
`jupyter_ai_magics` without installing `jupyterlab` or `jupyter_ai`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"nx": "^15.9.2"
},
"resolutions": {
"@jupyterlab/completer": "^4.1.0"
"@jupyterlab/completer": "^4.2.0"
},
"nx": {
"includedScripts": []
Expand Down
32 changes: 16 additions & 16 deletions packages/jupyter-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@jupyter/collaboration": "^1",
"@jupyterlab/application": "^4",
"@jupyterlab/apputils": "^4",
"@jupyterlab/cells": "^4",
"@jupyterlab/codeeditor": "^4",
"@jupyterlab/codemirror": "^4",
"@jupyterlab/completer": "^4",
"@jupyterlab/coreutils": "^6",
"@jupyterlab/docregistry": "^4",
"@jupyterlab/fileeditor": "^4",
"@jupyterlab/notebook": "^4",
"@jupyterlab/rendermime": "^4",
"@jupyterlab/services": "^7",
"@jupyterlab/settingregistry": "^4",
"@jupyterlab/ui-components": "^4",
"@jupyterlab/application": "^4.2.0",
"@jupyterlab/apputils": "^4.2.0",
"@jupyterlab/cells": "^4.2.0",
"@jupyterlab/codeeditor": "^4.2.0",
"@jupyterlab/codemirror": "^4.2.0",
"@jupyterlab/completer": "^4.2.0",
"@jupyterlab/coreutils": "^6.2.0",
"@jupyterlab/docregistry": "^4.2.0",
"@jupyterlab/fileeditor": "^4.2.0",
"@jupyterlab/notebook": "^4.2.0",
"@jupyterlab/rendermime": "^4.2.0",
"@jupyterlab/services": "^7.2.0",
"@jupyterlab/settingregistry": "^4.2.0",
"@jupyterlab/ui-components": "^4.2.0",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.0",
"react": "^18.2.0",
Expand All @@ -84,8 +84,8 @@
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@jupyterlab/builder": "^4",
"@jupyterlab/testutils": "^4",
"@jupyterlab/builder": "^4.2.0",
"@jupyterlab/testutils": "^4.2.0",
"@types/jest": "^29",
"@types/react-dom": "^18.2.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
Expand Down
10 changes: 3 additions & 7 deletions packages/jupyter-ai/src/contexts/active-cell-context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useContext, useEffect } from 'react';

import { JupyterFrontEnd, LabShell } from '@jupyterlab/application';
import { JupyterFrontEnd } from '@jupyterlab/application';
import { DocumentWidget } from '@jupyterlab/docregistry';
import { Notebook, NotebookActions } from '@jupyterlab/notebook';
import { Cell } from '@jupyterlab/cells';
Expand Down Expand Up @@ -56,12 +56,8 @@ type CellWithErrorContent = {
*/
export class ActiveCellManager {
constructor(shell: JupyterFrontEnd.IShell) {
if (!(shell instanceof LabShell)) {
throw 'Shell is not an instance of LabShell. Jupyter AI does not currently support custom shells.';
}

this._shell = shell;
this._shell.currentChanged.connect((sender, args) => {
this._shell.currentChanged?.connect((sender, args) => {
this._mainAreaWidget = args.newValue;
});

Expand Down Expand Up @@ -229,7 +225,7 @@ export class ActiveCellManager {
}
}

protected _shell: LabShell;
protected _shell: JupyterFrontEnd.IShell;
protected _mainAreaWidget: Widget | null = null;

/**
Expand Down
10 changes: 3 additions & 7 deletions packages/jupyter-ai/src/selection-watcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JupyterFrontEnd, LabShell } from '@jupyterlab/application';
import { JupyterFrontEnd } from '@jupyterlab/application';
import { DocumentWidget } from '@jupyterlab/docregistry';
import { CodeEditor } from '@jupyterlab/codeeditor';
import { CodeMirrorEditor } from '@jupyterlab/codemirror';
Expand Down Expand Up @@ -101,12 +101,8 @@ export type Selection = CodeEditor.ITextSelection & {

export class SelectionWatcher {
constructor(shell: JupyterFrontEnd.IShell) {
if (!(shell instanceof LabShell)) {
throw 'Shell is not an instance of LabShell. Jupyter AI does not currently support custom shells.';
}

this._shell = shell;
this._shell.currentChanged.connect((sender, args) => {
this._shell.currentChanged?.connect((sender, args) => {
this._mainAreaWidget = args.newValue;
});

Expand Down Expand Up @@ -169,7 +165,7 @@ export class SelectionWatcher {
this._selectionChanged.emit(currSelection);
}

protected _shell: LabShell;
protected _shell: JupyterFrontEnd.IShell;
protected _mainAreaWidget: Widget | null = null;
protected _selection: Selection | null = null;
protected _selectionChanged = new Signal<this, Selection | null>(this);
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyter-ai/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const statusItemPlugin: JupyterFrontEndPlugin<IJaiStatusItem> = {
id: 'jupyter_ai:status-item',
description: 'Provides a status item for Jupyter AI.',
autoStart: true,
requires: [IStatusBar],
optional: [IStatusBar],
provides: IJaiStatusItem,
activate: (app: JupyterFrontEnd, statusBar: IStatusBar | null) => {
const statusItem = new JaiStatusItem({
Expand Down
Loading

0 comments on commit ff022fe

Please sign in to comment.