Skip to content

Commit 1175cfc

Browse files
Backport PR jupyterlab#1087: Improve installation documentation and clarify provider dependencies (jupyterlab#1091)
Co-authored-by: Sanjiv Das <[email protected]>
1 parent a8be64f commit 1175cfc

File tree

2 files changed

+128
-40
lines changed

2 files changed

+128
-40
lines changed

Diff for: README.md

+61-7
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,80 @@ Below is a simplified overview of the installation and usage process.
5353
See [our official documentation](https://jupyter-ai.readthedocs.io/en/latest/users/index.html)
5454
for details on installing and using Jupyter AI.
5555

56-
### With pip
56+
We offer 3 different ways to install Jupyter AI. You can read through each
57+
section to pick the installation method that works best for you.
58+
59+
1. Quick installation via `pip` (recommended)
60+
2. Minimal installation via `pip`
61+
3. Minimal installation via `conda`
62+
63+
### Quick installation via `pip` (recommended)
5764

5865
If you want to install both the `%%ai` magic and the JupyterLab extension, you can run:
5966

60-
$ pip install jupyter-ai
67+
$ pip install jupyter-ai[all]
68+
69+
Then, restart JupyterLab. This will install every optional dependency, which
70+
provides access to all models currently supported by `jupyter-ai`.
6171

62-
If you are not using JupyterLab and you only want to install the Jupyter AI `%%ai` magic, you can run:
72+
If you are not using JupyterLab and you only want to install the Jupyter AI
73+
`%%ai` magic, you can run:
6374

64-
$ pip install jupyter-ai-magics
75+
$ pip install jupyter-ai-magics[all]
6576

77+
`jupyter-ai` depends on `jupyter-ai-magics`, so installing `jupyter-ai`
78+
automatically installs `jupyter-ai-magics`.
6679

67-
### With conda
80+
### Minimal installation via `pip`
81+
82+
Most model providers in Jupyter AI require a specific dependency to be installed
83+
before they are available for use. These are called _provider dependencies_.
84+
Provider dependencies are optional to Jupyter AI, meaning that Jupyter AI can be
85+
installed with or without any provider dependencies installed. If a provider
86+
requires a dependency that is not installed, its models are not listed in the
87+
user interface which allows you to select a language model.
88+
89+
To perform a minimal installation via `pip` without any provider dependencies,
90+
omit the `[all]` optional dependency group from the package name:
91+
92+
```
93+
pip install jupyter-ai
94+
```
95+
96+
By selectively installing provider dependencies, you can control which models
97+
are available in your Jupyter AI environment.
98+
99+
For example, to install Jupyter AI with only added support for Anthropic models, run:
100+
101+
```
102+
pip install jupyter-ai langchain-anthropic
103+
```
104+
105+
For more information on model providers and which dependencies they require, see
106+
[the model provider table](https://jupyter-ai.readthedocs.io/en/latest/users/index.html#model-providers).
107+
108+
### Minimal installation via `conda`
68109

69110
As an alternative to using `pip`, you can install `jupyter-ai` using
70111
[Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
71-
from the `conda-forge` channel, using one of the following two commands:
112+
from the `conda-forge` channel:
72113

73-
$ conda install -c conda-forge jupyter-ai # or,
74114
$ conda install conda-forge::jupyter-ai
75115

116+
Most model providers in Jupyter AI require a specific _provider dependency_ to
117+
be installed before they are available for use. Provider dependencies are
118+
not installed when installing `jupyter-ai` from Conda Forge, and should be
119+
installed separately as needed.
120+
121+
For example, to install Jupyter AI with only added support for OpenAI models, run:
122+
123+
```
124+
conda install conda-forge::jupyter-ai conda-forge::langchain-openai
125+
```
126+
127+
For more information on model providers and which dependencies they require, see
128+
[the model provider table](https://jupyter-ai.readthedocs.io/en/latest/users/index.html#model-providers).
129+
76130
## The `%%ai` magic command
77131

78132
The `%%ai` magic works anywhere the IPython kernel runs, including JupyterLab, Jupyter Notebook, Google Colab, and Visual Studio Code.

Diff for: docs/source/users/index.md

+67-33
Original file line numberDiff line numberDiff line change
@@ -79,62 +79,96 @@ classes in their code.
7979

8080
## Installation
8181

82-
### Installation via `pip`
82+
### Setup: creating a Jupyter AI environment (recommended)
8383

84-
To install the JupyterLab extension, you can run:
84+
Before installing Jupyter AI, we highly recommend first creating a separate
85+
Conda environment for Jupyter AI. This prevents the installation process from
86+
clobbering Python packages in your existing Python environment.
8587

86-
```
87-
pip install jupyter-ai
88-
```
88+
To do so, install
89+
[conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
90+
and create an environment that uses Python 3.12 and the latest version of
91+
JupyterLab:
8992

90-
You may need to install third-party packages, for example, to use some model providers and some file formats with Jupyter AI. To handle all supported use cases, you can install every dependency, which will give you access to all models currently supported by `jupyter-ai`. To install every dependency, run the following command, and then restart JupyterLab:
93+
$ conda create -n jupyter-ai python=3.12 jupyterlab
94+
$ conda activate jupyter-ai
9195

92-
```
93-
pip install jupyter-ai[all]
94-
```
96+
You can now choose how to install Jupyter AI.
9597

96-
The latest major version of `jupyter-ai`, v2, only supports JupyterLab 4. If you
97-
need support for JupyterLab 3, you should install `jupyter-ai` v1 instead:
98+
We offer 3 different ways to install Jupyter AI. You can read through each
99+
section to pick the installation method that works best for you.
98100

99-
```
100-
pip install jupyter-ai~=1.0
101-
```
101+
1. Quick installation via `pip` (recommended)
102+
2. Minimal installation via `pip`
103+
3. Minimal installation via `conda`
102104

103-
If you are not using JupyterLab and you only want to install the Jupyter AI `%%ai` magic, you can run:
105+
### Quick installation via `pip` (recommended)
104106

105-
```
106-
$ pip install jupyter-ai-magics
107-
```
107+
If you want to install both the `%%ai` magic and the JupyterLab extension, you can run:
108+
109+
$ pip install jupyter-ai[all]
110+
111+
Then, restart JupyterLab. This will install every optional dependency, which
112+
provides access to all models currently supported by `jupyter-ai`.
113+
114+
If you are not using JupyterLab and you only want to install the Jupyter AI
115+
`%%ai` magic, you can run:
116+
117+
$ pip install jupyter-ai-magics[all]
108118

109119
`jupyter-ai` depends on `jupyter-ai-magics`, so installing `jupyter-ai`
110120
automatically installs `jupyter-ai-magics`.
111121

112-
### Installation via `pip` or `conda` in a Conda environment (recommended)
122+
### Minimal installation via `pip`
113123

114-
We highly recommend installing both JupyterLab and Jupyter AI within an isolated
115-
Conda environment to avoid clobbering Python packages in your existing Python
116-
environment.
124+
Most model providers in Jupyter AI require a specific dependency to be installed
125+
before they are available for use. These are called _provider dependencies_.
126+
Provider dependencies are optional to Jupyter AI, meaning that Jupyter AI can be
127+
installed with or without any provider dependencies installed. If a provider
128+
requires a dependency that is not installed, its models are not listed in the
129+
user interface which allows you to select a language model.
117130

118-
First, install
119-
[conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
120-
and create an environment that uses Python 3.12:
131+
To perform a minimal installation via `pip` without any provider dependencies,
132+
omit the `[all]` optional dependency group from the package name:
121133

122-
$ conda create -n jupyter-ai python=3.12
123-
$ conda activate jupyter-ai
134+
```
135+
pip install jupyter-ai
136+
```
137+
138+
By selectively installing provider dependencies, you can control which models
139+
are available in your Jupyter AI environment.
140+
141+
For example, to install Jupyter AI with only added support for Anthropic models, run:
124142

125-
Then, use `conda` to install JupyterLab and Jupyter AI in this Conda environment.
143+
```
144+
pip install jupyter-ai langchain-anthropic
145+
```
146+
147+
For more information on model providers and which dependencies they require, see
148+
[the model provider table](https://jupyter-ai.readthedocs.io/en/latest/users/index.html#model-providers).
149+
150+
### Minimal installation via `conda`
151+
152+
As an alternative to using `pip`, you can install `jupyter-ai` using
153+
[Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
154+
from the `conda-forge` channel:
126155

127-
$ conda install -c conda-forge jupyter-ai # or,
128156
$ conda install conda-forge::jupyter-ai
129157

130-
When starting JupyterLab with Jupyter AI, make sure to activate the Conda
131-
environment first:
158+
Most model providers in Jupyter AI require a specific _provider dependency_ to
159+
be installed before they are available for use. Provider dependencies are
160+
not installed when installing `jupyter-ai` from Conda Forge, and should be
161+
installed separately as needed.
162+
163+
For example, to install Jupyter AI with only added support for OpenAI models, run:
132164

133165
```
134-
conda activate jupyter-ai
135-
jupyter lab
166+
conda install conda-forge::jupyter-ai conda-forge::langchain-openai
136167
```
137168

169+
For more information on model providers and which dependencies they require, see
170+
[the model provider table](https://jupyter-ai.readthedocs.io/en/latest/users/index.html#model-providers).
171+
138172
## Uninstallation
139173

140174
If you installed Jupyter AI using `pip`, to remove the extension, run:

0 commit comments

Comments
 (0)