Skip to content

Commit ff022fe

Browse files
jtpiodlqqq
andauthored
Support Notebook 7 (#827)
* 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]>
1 parent f875fef commit ff022fe

File tree

8 files changed

+585
-821
lines changed

8 files changed

+585
-821
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Documentation is available on [ReadTheDocs](https://jupyter-ai.readthedocs.io/en
2323
You will need to have installed the following software to use Jupyter AI:
2424

2525
- Python 3.8 - 3.11
26-
- JupyterLab 4
26+
- JupyterLab 4 or Notebook 7
2727

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

docs/source/users/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ conda config --set channel_priority strict
4747
conda install jupyterlab~=4.0
4848
```
4949

50+
You can also use Jupyter AI in Jupyter Notebook 7.2+. To install Jupyter Notebook 7.2:
51+
52+
1. via `pip`:
53+
54+
```
55+
pip install notebook~=7.2
56+
```
57+
58+
2. via `conda`:
59+
```
60+
conda install notebook~=7.2
61+
```
62+
63+
:::{note}
64+
To activate the chat interface in Jupyter Notebook, click on "View > Left sidebar > Show Jupyter AI Chat".
65+
:::
66+
5067
The `jupyter_ai_magics` package, which provides exclusively the IPython magics,
5168
does not depend on JupyterLab or `jupyter_ai`. You can install
5269
`jupyter_ai_magics` without installing `jupyterlab` or `jupyter_ai`.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"nx": "^15.9.2"
4343
},
4444
"resolutions": {
45-
"@jupyterlab/completer": "^4.1.0"
45+
"@jupyterlab/completer": "^4.2.0"
4646
},
4747
"nx": {
4848
"includedScripts": []

packages/jupyter-ai/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@
6262
"@emotion/react": "^11.10.5",
6363
"@emotion/styled": "^11.10.5",
6464
"@jupyter/collaboration": "^1",
65-
"@jupyterlab/application": "^4",
66-
"@jupyterlab/apputils": "^4",
67-
"@jupyterlab/cells": "^4",
68-
"@jupyterlab/codeeditor": "^4",
69-
"@jupyterlab/codemirror": "^4",
70-
"@jupyterlab/completer": "^4",
71-
"@jupyterlab/coreutils": "^6",
72-
"@jupyterlab/docregistry": "^4",
73-
"@jupyterlab/fileeditor": "^4",
74-
"@jupyterlab/notebook": "^4",
75-
"@jupyterlab/rendermime": "^4",
76-
"@jupyterlab/services": "^7",
77-
"@jupyterlab/settingregistry": "^4",
78-
"@jupyterlab/ui-components": "^4",
65+
"@jupyterlab/application": "^4.2.0",
66+
"@jupyterlab/apputils": "^4.2.0",
67+
"@jupyterlab/cells": "^4.2.0",
68+
"@jupyterlab/codeeditor": "^4.2.0",
69+
"@jupyterlab/codemirror": "^4.2.0",
70+
"@jupyterlab/completer": "^4.2.0",
71+
"@jupyterlab/coreutils": "^6.2.0",
72+
"@jupyterlab/docregistry": "^4.2.0",
73+
"@jupyterlab/fileeditor": "^4.2.0",
74+
"@jupyterlab/notebook": "^4.2.0",
75+
"@jupyterlab/rendermime": "^4.2.0",
76+
"@jupyterlab/services": "^7.2.0",
77+
"@jupyterlab/settingregistry": "^4.2.0",
78+
"@jupyterlab/ui-components": "^4.2.0",
7979
"@mui/icons-material": "^5.11.0",
8080
"@mui/material": "^5.11.0",
8181
"react": "^18.2.0",
@@ -84,8 +84,8 @@
8484
"devDependencies": {
8585
"@babel/core": "^7.0.0",
8686
"@babel/preset-env": "^7.0.0",
87-
"@jupyterlab/builder": "^4",
88-
"@jupyterlab/testutils": "^4",
87+
"@jupyterlab/builder": "^4.2.0",
88+
"@jupyterlab/testutils": "^4.2.0",
8989
"@types/jest": "^29",
9090
"@types/react-dom": "^18.2.0",
9191
"@typescript-eslint/eslint-plugin": "^4.8.1",

packages/jupyter-ai/src/contexts/active-cell-context.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useContext, useEffect } from 'react';
22

3-
import { JupyterFrontEnd, LabShell } from '@jupyterlab/application';
3+
import { JupyterFrontEnd } from '@jupyterlab/application';
44
import { DocumentWidget } from '@jupyterlab/docregistry';
55
import { Notebook, NotebookActions } from '@jupyterlab/notebook';
66
import { Cell } from '@jupyterlab/cells';
@@ -56,12 +56,8 @@ type CellWithErrorContent = {
5656
*/
5757
export class ActiveCellManager {
5858
constructor(shell: JupyterFrontEnd.IShell) {
59-
if (!(shell instanceof LabShell)) {
60-
throw 'Shell is not an instance of LabShell. Jupyter AI does not currently support custom shells.';
61-
}
62-
6359
this._shell = shell;
64-
this._shell.currentChanged.connect((sender, args) => {
60+
this._shell.currentChanged?.connect((sender, args) => {
6561
this._mainAreaWidget = args.newValue;
6662
});
6763

@@ -229,7 +225,7 @@ export class ActiveCellManager {
229225
}
230226
}
231227

232-
protected _shell: LabShell;
228+
protected _shell: JupyterFrontEnd.IShell;
233229
protected _mainAreaWidget: Widget | null = null;
234230

235231
/**

packages/jupyter-ai/src/selection-watcher.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { JupyterFrontEnd, LabShell } from '@jupyterlab/application';
1+
import { JupyterFrontEnd } from '@jupyterlab/application';
22
import { DocumentWidget } from '@jupyterlab/docregistry';
33
import { CodeEditor } from '@jupyterlab/codeeditor';
44
import { CodeMirrorEditor } from '@jupyterlab/codemirror';
@@ -101,12 +101,8 @@ export type Selection = CodeEditor.ITextSelection & {
101101

102102
export class SelectionWatcher {
103103
constructor(shell: JupyterFrontEnd.IShell) {
104-
if (!(shell instanceof LabShell)) {
105-
throw 'Shell is not an instance of LabShell. Jupyter AI does not currently support custom shells.';
106-
}
107-
108104
this._shell = shell;
109-
this._shell.currentChanged.connect((sender, args) => {
105+
this._shell.currentChanged?.connect((sender, args) => {
110106
this._mainAreaWidget = args.newValue;
111107
});
112108

@@ -169,7 +165,7 @@ export class SelectionWatcher {
169165
this._selectionChanged.emit(currSelection);
170166
}
171167

172-
protected _shell: LabShell;
168+
protected _shell: JupyterFrontEnd.IShell;
173169
protected _mainAreaWidget: Widget | null = null;
174170
protected _selection: Selection | null = null;
175171
protected _selectionChanged = new Signal<this, Selection | null>(this);

packages/jupyter-ai/src/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const statusItemPlugin: JupyterFrontEndPlugin<IJaiStatusItem> = {
1010
id: 'jupyter_ai:status-item',
1111
description: 'Provides a status item for Jupyter AI.',
1212
autoStart: true,
13-
requires: [IStatusBar],
13+
optional: [IStatusBar],
1414
provides: IJaiStatusItem,
1515
activate: (app: JupyterFrontEnd, statusBar: IStatusBar | null) => {
1616
const statusItem = new JaiStatusItem({

0 commit comments

Comments
 (0)