Skip to content

Commit

Permalink
Fix cookiecutter template (#637)
Browse files Browse the repository at this point in the history
* delete binder related boilerplate

* remove unused github workflows

* remove frontend boilerplate, update provider template

* add slash command template

* tweak wording

* add contributor docs for cookiecutter use

* pre-commit

* fix cookiecutter GH link

Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>

* add pip install cookiecutter

---------

Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
  • Loading branch information
dlqqq and krassowski authored Feb 14, 2024
1 parent 40ff68c commit 6639c66
Show file tree
Hide file tree
Showing 52 changed files with 281 additions and 1,545 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ dev.sh
.yarn

.conda/

# reserved for testing cookiecutter
packages/jupyter-ai-test
34 changes: 34 additions & 0 deletions docs/source/developers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,40 @@ For more details about using `langchain.pydantic_v1` in an environment with
Pydantic v2 installed, see the
[LangChain documentation on Pydantic compatibility](https://python.langchain.com/docs/guides/pydantic_compatibility).

## Jupyter AI module cookiecutter

We offer a [cookiecutter](https://github.com/cookiecutter/cookiecutter) template
that can be used to generate a pre-configured Jupyter AI module. This is a
Python package that exposes a template model provider and slash command for
integration with Jupyter AI. Developers can then extend the generated AI module
however they wish.

To generate a new AI module using the cookiecutter, run these commands from the
repository root:

```
pip install cookiecutter
cd packages/
cookiecutter jupyter-ai-module-cookiecutter
```

The last command will open a wizard that allows you to set the package name and
a few other metadata fields. By default, the package will have the name `jupyter-ai-test`.

To install your new AI module locally and use the generated template provider
and slash command:

```
cd jupyter-ai-test/
pip install -e .
```

You will then be able to use the test provider and slash command after
restarting JupyterLab.

The remainder of this documentation page elaborates on how to define a custom
model provider and slash command.

## Custom model providers

You can define new providers using the LangChain framework API. Custom providers
Expand Down
120 changes: 0 additions & 120 deletions packages/jupyter-ai-module-cookiecutter/.gitignore

This file was deleted.

29 changes: 0 additions & 29 deletions packages/jupyter-ai-module-cookiecutter/LICENSE

This file was deleted.

31 changes: 15 additions & 16 deletions packages/jupyter-ai-module-cookiecutter/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Jupyter AI Module Cookiecutter
# Jupyter AI module cookiecutter

A [cookiecutter](https://github.com/audreyr/cookiecutter) template for creating
a AI module. The AI module constructed from the template serves as a very simple
example that can be extended however you wish.
A [cookiecutter](https://github.com/cookiecutter/cookiecutter) template for creating
a Jupyter AI module. A Jupyter AI module is a Python package that registers
additional model providers (containing language and embedding models) and slash
commands for Jupyter AI.

This cookiecutter generates a simple AI module that provides a test model
provider and slash command implementation that can be used in Jupyter AI once
installed. Developers should use this as a template to implement additional
functionality on top of Jupyter AI.

## Usage

Expand All @@ -19,20 +25,13 @@ cd packages/
cookiecutter jupyter-ai-module-cookiecutter
```

Follow the prompts to create a new AI module under `packages/`. Your
labextension name should use hyphens, whereas your Python name should use
underscores.

# Usage (monorepo integration)
Follow the prompts to create a new AI module under `packages/`.

To integrate the new AI module into this monorepo, execute this command
manually from the AI module root:
To install the new AI module locally:

```
rm -r .github/ binder/ CHANGELOG.md RELEASE.md
cd "<jai-module-root-dir>"
pip install -e "."
```

Rename the JS package to be scoped under `@jupyter-ai/`.

Finally, add the Python package to the `options.python_packages` field in
`.jupyter-releaser.toml`.
See the `README.md` under the root directory for more information.
9 changes: 3 additions & 6 deletions packages/jupyter-ai-module-cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
"author_name": "Project Jupyter",
"author_email": "jupyter@googlegroups.com",
"version": "0.1.0",
"labextension_name": "myextension",
"python_name": "{{ cookiecutter.labextension_name | replace('-', '_') }}",
"project_short_description": "A JupyterLab extension.",
"has_settings": "n",
"has_binder": "n",
"test": "y",
"python_name": "jupyter_ai_test",
"root_dir_name": "{{ cookiecutter.python_name | replace('_', '-') }}",
"project_short_description": "Jupyter AI",
"repository": "https://github.com/jupyterlab/jupyter-ai"
}
40 changes: 0 additions & 40 deletions packages/jupyter-ai-module-cookiecutter/hooks/post_gen_project.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6639c66

Please sign in to comment.