Skip to content

Commit 9e535fd

Browse files
authored
Overhaul v3 developer documentation (#1344)
* overhaul developer docs for v3 * pre-commit * lay out new dev docs page structure * add embedding model providers to EP API * add personas documentation * pre-commit * remove duplicate content * add section on using Jupyternaut's model * remove unused inline_completions.md, already copied * remove ampersands as suggested by @srdas * title-case 'How-to' sections as suggested by @srdas
1 parent 4e1df34 commit 9e535fd

File tree

6 files changed

+634
-645
lines changed

6 files changed

+634
-645
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# `'jupyter_ai.embeddings_model_providers'`
2+
3+
```{contents} Contents
4+
```
5+
6+
## Summary
7+
8+
This entry point group allows packages to add custom embedding model providers
9+
to power the retrieval-augmented generation (RAG) capabilities of Jupyter AI.
10+
11+
This group expects an **embedding model provider class**, a subclass of
12+
`BaseEmbeddingsProvider` from `jupyter-ai` that also inherits from an
13+
`Embeddings` class from LangChain. Instructions on defining one are given in the
14+
next section.
15+
16+
:::{warning}
17+
This is a v2 extension point that may be removed in v3. In v3, we may explore
18+
updating the model API to make it easier for developers to add custom models.
19+
:::
20+
21+
## How-to: Define a custom embedding model provider
22+
23+
```python
24+
from jupyter_ai_magics import BaseEmbeddingsProvider
25+
from langchain.embeddings import FakeEmbeddings
26+
27+
class MyEmbeddingsProvider(BaseEmbeddingsProvider, FakeEmbeddings):
28+
id = "my_embeddings_provider"
29+
name = "My Embeddings Provider"
30+
model_id_key = "model"
31+
models = ["my_model"]
32+
33+
def __init__(self, **kwargs):
34+
super().__init__(size=300, **kwargs)
35+
```
36+
37+
Jupyter AI uses entry points to discover embedding providers.
38+
In the `pyproject.toml` file, add your custom embedding provider to the
39+
`[project.entry-points."jupyter_ai.embeddings_model_providers"]` section:
40+
41+
```toml
42+
[project.entry-points."jupyter_ai.embeddings_model_providers"]
43+
my-provider = "my_provider:MyEmbeddingsProvider"
44+
```
45+
46+
[Embeddings]: https://api.python.langchain.com/en/stable/embeddings/langchain_core.embeddings.Embeddings.html
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Entry points API
2+
3+
The [**entry points API**][entry_points] allows other packages to add custom
4+
objects to Jupyter AI's backend. Jupyter AI defines a set of **entry point
5+
groups**. Each entry point group is reserved for a specific type of object, e.g.
6+
one group may be reserved for personas and another may be reserved for model
7+
providers.
8+
9+
A package can *provide* an **entry point** to an entry point group to add an
10+
object of the type reserved by the group. For example, providing an entry point
11+
to the personas group will add a new AI persona to Jupyter AI. A package can
12+
also provide multiple entry points to the same group.
13+
14+
The entry points API currently includes the following entry point groups:
15+
16+
- `'jupyter_ai.personas'`: allows developers to add AI personas.
17+
18+
- `'jupyter_ai.model_providers'`: allows developers to add model providers.
19+
20+
- `'jupyter_ai.embeddings_model_providers'`: allows developers to add embedding model providers.
21+
22+
Each entry point group used by Jupyter AI is documented in a section below,
23+
which describes the type of object expected and how to define a custom
24+
implementation.
25+
26+
At the end, we describe how to provide an entry point using a custom
27+
implementation in your package.
28+
29+
```{toctree}
30+
:caption: Contents
31+
32+
personas_group.md
33+
model_providers_group.md
34+
embeddings_providers_group.md
35+
providing_entry_points.md
36+
```
37+
38+
[entry_points]: https://setuptools.pypa.io/en/latest/userguide/entry_point.html

0 commit comments

Comments
 (0)