Skip to content

Overhaul v3 developer documentation #1344

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

dlqqq
Copy link
Member

@dlqqq dlqqq commented May 22, 2025

Description

  • Closes [v3-beta] Document personas API #1343.
  • Structures the developer documentation to be much more legible.
    • Breaks the wall of text into multiple sub-pages.
    • Explicitly lists each entry point group used by Jupyter AI & their expected type.
    • Includes a "how-to" for each group.
  • Adds a page on providing entry points from a package. This addresses a very common issue reported by new developers.
  • Removes outdated documentation from the v3 developer documentation:
    • Removes docs on custom slash commands, as they now be managed by personas in v3.
    • Removes docs on Pydantic version compatibility, as we do not use Pydantic v1 in JAI v3.
    • Removes docs on the JAI module cookiecutter, as it is unclear if we will continue to maintain that for v3.
    • Removes docs on the v2 message footer API, as that no longer works with the new jupyterlab_chat frontend.
  • Adds a documentation page on custom AI personas.

Demo

The new dev docs look much nicer. See demo: https://jupyter-ai--1344.org.readthedocs.build/en/1344/developers/index.html

@dlqqq dlqqq added documentation Improvements or additions to documentation do-not-port Label for PRs that shouldn't be ported to another branch labels May 22, 2025
@dlqqq dlqqq marked this pull request as draft May 22, 2025 00:18
@dlqqq dlqqq changed the title [WIP] Add v3 developer documentation Overhaul v3 developer documentation May 22, 2025
@dlqqq dlqqq marked this pull request as ready for review May 22, 2025 17:54
@dlqqq
Copy link
Member Author

dlqqq commented May 22, 2025

@fperez Hey Fernando, this PR adds documentation on defining custom AI personas & providing them to Jupyter AI via entry points. 👍

The Jupyter AI docs have been split into 2 versions: v2 and v3. The docs page defaults to v2 for now, since v3.0.0 isn't released yet. If you have trouble finding these docs after this PR is merged, be sure to switch to the v3 docs site using the pop-up on the bottom-right:

Screenshot 2025-05-22 at 11 20 17 AM

@dlqqq
Copy link
Member Author

dlqqq commented May 22, 2025

You can also click the link in the PR description to view the developer documentation right now, before this PR is merged.

@srdas srdas self-assigned this May 22, 2025

## How-to: define custom code completions

Any model provider derived from `BaseProvider` can be used as a completion provider.
Copy link
Member

Choose a reason for hiding this comment

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

This and everything below is roughly duplicated in inline_completions.md. I don't know which copy you intended to keep but just highlighting this with assumption that only one was meant to be included.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch, thanks! I'll look into this when I'm able

```

Jupyter AI uses entry points to discover embedding providers.
In the `pyproject.toml` file, add your custom embedding provider to the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mention here that the specific pyproject.toml file is in jupyter-ai-magics.

The [**entry points API**][entry_points] allows other packages to add custom
objects to Jupyter AI's backend. Jupyter AI defines a set of **entry point
groups**. Each entry point group is reserved for a specific type of object, e.g.
one group may be reserved for personas and another may be reserved for model
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's out convention for personas, do we want to capitalize it to Personas?


The `auth_strategy` handles specifying API keys for providers and models.
The example shows the `EnvAuthStrategy` which takes the API key from the
environment variable with the name specified in `name` and be provided to the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awkward sentence, maybe use "it will be" instead of just "be"

For example, if your Jupyter AI instance has `Jupyternaut` and `MyCustomPersona`
as 2 AI personas, then each persona will only respond when `@`-mentioned.

- To call `Jupyternaut`, your message must include `@Jupyternaut`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be better to say that the message should be prefixed by @Jupyternaut?

`jupyter_ai.personas:BasePersona`. Instructions on defining one are given in the
next section.

## How-to: define a custom AI persona
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capitalize "Define"

`process_message()` method.

- `defaults` defines the default settings of the persona. This is mainly used to
control the name & avatar shown in the Jupyter AI chat.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace & with "and"

by Jupyternaut, you can access that through the `self.config: ConfigManager`
attribute available to subclasses.

Add & call this method on a persona to access the LangChain runnable used by
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace & with "and"

To provide entry points, your custom Python package must use a `pyproject.toml`
manifest. To provide an existing class as an entry point, fill out the following
template and add it to the end of your package's
`pyproject.toml` file.
Copy link
Collaborator

Choose a reason for hiding this comment

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

add to the end of the sentence: "in the jupyter-ai-test folder"

Copy link
Collaborator

@srdas srdas left a comment

Choose a reason for hiding this comment

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

The docs look really good. Left some comments. Questions:

  1. Will we be moving Personas out from jupyter-ai-test into their own folder under jupyter-ai?
  2. Should Personas and all related files (READMEs, tools, requirements) be in subfolders under a separate folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-port Label for PRs that shouldn't be ported to another branch documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v3-beta] Document personas API
3 participants