forked from jupyterlab/jupyter-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import ChatGPT AI module (jupyterlab#14)
* declare jupyter_ai dependency for AI modules * fix cookiecutter eslint * fix dev install script * add setup:dev script to cookiecutter * finish renaming remaining occurrences of TestModelEngine * remove concurrency flag on lerna commands * import ChatGPT AI module * use chatgpt model engine for default tasks
- Loading branch information
Showing
41 changed files
with
981 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules | ||
dist | ||
coverage | ||
**/*.d.ts | ||
tests | ||
|
||
**/__tests__ | ||
ui-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module.exports = { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended' | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: './tsconfig.json' | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
selector: 'interface', | ||
format: ['PascalCase'], | ||
custom: { | ||
regex: '^I[A-Z]', | ||
match: true | ||
} | ||
} | ||
], | ||
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-namespace': 'off', | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/quotes': [ | ||
'error', | ||
'single', | ||
{ avoidEscape: true, allowTemplateLiterals: false } | ||
], | ||
curly: ['error', 'all'], | ||
eqeqeq: 'error', | ||
'prefer-arrow-callback': 'error' | ||
}, | ||
overrides: { | ||
files: ['src/**/*'] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
*.bundle.* | ||
lib/ | ||
node_modules/ | ||
*.log | ||
.eslintcache | ||
.stylelintcache | ||
*.egg-info/ | ||
.ipynb_checkpoints | ||
*.tsbuildinfo | ||
jupyter_ai_chatgpt/labextension | ||
# Version file is handled by hatchling | ||
jupyter_ai_chatgpt/_version.py | ||
|
||
# Integration tests | ||
ui-tests/test-results/ | ||
ui-tests/playwright-report/ | ||
|
||
# Created by https://www.gitignore.io/api/python | ||
# Edit at https://www.gitignore.io/?templates=python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage/ | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# End of https://www.gitignore.io/api/python | ||
|
||
# OSX files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
**/node_modules | ||
**/lib | ||
**/package.json | ||
!/package.json | ||
jupyter_ai_chatgpt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"arrowParens": "avoid", | ||
"endOfLine": "auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": [ | ||
"stylelint-config-recommended", | ||
"stylelint-config-standard", | ||
"stylelint-prettier/recommended" | ||
], | ||
"rules": { | ||
"property-no-vendor-prefix": null, | ||
"selector-no-vendor-prefix": null, | ||
"value-no-vendor-prefix": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2023, Project Jupyter | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# jupyter_ai_chatgpt | ||
|
||
This extension is composed of a Python package named `jupyter_ai_chatgpt` | ||
that exposes the model engines to the Jupyter AI server extension, | ||
and an NPM package named `@jupyter-ai/chatgpt` | ||
that provides a frontend labextension registering inserters. | ||
|
||
## Requirements | ||
|
||
- JupyterLab >= 3.0 | ||
|
||
## Install | ||
|
||
To install the extension, execute: | ||
|
||
```bash | ||
pip install jupyter_ai_chatgpt | ||
``` | ||
|
||
## Uninstall | ||
|
||
To remove the extension, execute: | ||
|
||
```bash | ||
pip uninstall jupyter_ai_chatgpt | ||
``` | ||
## Contributing | ||
|
||
### Development install | ||
|
||
Note: You will need NodeJS to build the extension package. | ||
|
||
The `jlpm` command is JupyterLab's pinned version of | ||
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use | ||
`yarn` or `npm` in lieu of `jlpm` below. | ||
|
||
```bash | ||
# Clone the repo to your local environment | ||
# Change directory to the jupyter_ai_chatgpt directory | ||
# Install package in development mode | ||
pip install -e ".[test]" | ||
# Link your development version of the extension with JupyterLab | ||
jupyter labextension develop . --overwrite | ||
# Rebuild extension Typescript source after making changes | ||
jlpm build | ||
``` | ||
|
||
You can watch the source directory and run JupyterLab at the same time in | ||
different terminals to watch for changes in the extension's source and | ||
automatically rebuild the extension. | ||
|
||
```bash | ||
# Watch the source directory in one terminal, automatically rebuilding when needed | ||
jlpm watch | ||
# Run JupyterLab in another terminal | ||
jupyter lab | ||
``` | ||
|
||
With the watch command running, every saved change will immediately be built | ||
locally and available in your running JupyterLab. Refresh JupyterLab to load the | ||
change in your browser (you may need to wait several seconds for the extension | ||
to be rebuilt). | ||
|
||
By default, the `jlpm build` command generates the source maps for this | ||
extension to make it easier to debug using the browser dev tools. To also | ||
generate source maps for the JupyterLab core extensions, you can run the | ||
following command: | ||
|
||
```bash | ||
jupyter lab build --minimize=False | ||
``` | ||
|
||
### Development uninstall | ||
|
||
```bash | ||
pip uninstall jupyter_ai_chatgpt | ||
``` | ||
|
||
In development mode, you will also need to remove the symlink created by `jupyter labextension develop` | ||
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions` | ||
folder is located. Then you can remove the symlink named `@jupyter-ai/chatgpt` within that folder. | ||
|
||
### Testing the extension | ||
|
||
#### Backend tests | ||
|
||
This AI module is using [Pytest](https://docs.pytest.org/) for Python code testing. | ||
|
||
Install test dependencies (needed only once): | ||
|
||
```sh | ||
pip install -e ".[test]" | ||
# Each time you install the Python package, you need to restore the front-end extension link | ||
jupyter labextension develop . --overwrite | ||
``` | ||
|
||
To execute them, run: | ||
|
||
```sh | ||
pytest -vv -r ap --cov jupyter_ai_chatgpt | ||
``` | ||
|
||
#### Frontend tests | ||
|
||
This extension is using [Jest](https://jestjs.io/) for JavaScript code testing. | ||
|
||
To execute them, execute: | ||
|
||
```sh | ||
jlpm | ||
jlpm test | ||
``` | ||
|
||
#### Integration tests | ||
|
||
This extension uses [Playwright](https://playwright.dev/docs/intro/) for the integration tests (aka user level tests). | ||
More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab. | ||
|
||
More information are provided within the [ui-tests](./ui-tests/README.md) README. | ||
|
||
### Packaging the extension | ||
|
||
See [RELEASE](RELEASE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@jupyterlab/testutils/lib/babel.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"packageManager": "python", | ||
"packageName": "jupyter_ai_chatgpt", | ||
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyter_ai_chatgpt" | ||
} |
Oops, something went wrong.