Skip to content

Commit

Permalink
Mock request (#27)
Browse files Browse the repository at this point in the history
* Add E2E tests (jupyterlab#350)

* add basic e2e testing setup

* adjust execute test step name

* test sidebar chat icon, add testing class

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add sidebar snapshot

* test chat sidepanel, extend helper class

* adjust welcome message test, add snapshot

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* adjust naming

* removeempty line

* move ui-tests to packages/jupyter-ai/

* update e2e ci workflow for ui-tests folder move

* update ui-tests folder location for yarn.lock hash

* run lint locally

* Add "Update Playwright Snapshots" CI workflow

* change if clause

* specify npm client

* remove report and artifact specifiers

* Update README.md to have correct commands and folders

* update e2e/integration test README

* Add Integration / E2E testing section to the docs

* update wording of docs on snapshots

* Ignore all non-linux snapshots

* Update packages/jupyter-ai/ui-tests/README.md

Co-authored-by: Piyush Jain <piyushjain@duck.com>

* remove cd command that would return users back to root

* remove cd ../../../

* Remove repeating setup instructions

* Add suggestion to generate snapshots before the 1st run

* remove unnecessary link anchor

* remove rudimentary jlpm build

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Piyush Jain <piyushjain@duck.com>

* Adds chat anthropic provider, new models (jupyterlab#391)

* Adds chat anthropic provider, new models

* Added docs for anthropic chat

* Upgraded LangChain, fixed prompts for Bedrock

* Updated docs for bedrock-chat

* Added bedrock embeddings, refactored chat vs reg models

* Fixed magics

* Removed unused import

* Updated provider list.

Added bedrock and bedrock-chat to provider list.

* Publish 2.3.0

SHA256 hashes:

jupyter-ai-core-2.3.0.tgz: 8f37fe0f15b6f09b2eeb649ac972d2749427ed3668a03ffae9cf5b5f8f37a8ce

jupyter_ai-2.3.0-py3-none-any.whl: 09e264c40f05ef34cd188dd5804d22afe43a91e4c82ed729428377bd5c581263

jupyter_ai-2.3.0.tar.gz: 8ce44b88528195e6de1f9086994d68731b1dbbc03f0e8709baf5a8819c254462

jupyter_ai_magics-2.3.0-py3-none-any.whl: 714cf33746c121ef2b5d5c45b4460e690d6815b306a3f5f7224008866e794602

jupyter_ai_magics-2.3.0.tar.gz: 37554e53d3576a6c8938e5812764efe7749dfeda2f47d5e551111d2f6d8a5c48

* [pre-commit.ci] pre-commit autoupdate (jupyterlab#344)

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)
- [github.com/asottile/pyupgrade: v3.10.1 → v3.15.0](asottile/pyupgrade@v3.10.1...v3.15.0)
- [github.com/sirosen/check-jsonschema: 0.23.3 → 0.27.0](python-jsonschema/check-jsonschema@0.23.3...0.27.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Add key completion code completion

* Add developer readme

* Fix the bug of remote call not using stram

* Comment out useless methods and improve development documentation

* Updates for more stable generate feature

* Refactored generate for better stability with all providers/models.

* Upgraded LangChain to 0.0.318

* Updated to use memory instead of chat history, fix for Bedrock Anthropic

* Optimize code naming

* Fixed the issue where enter would intercept automatic requests

* Fixed the issue where enter fails when pressing the ghost text to start.

* Allow to define block and allow lists for providers (jupyterlab#415)

* Allow to block or allow-list providers by id

* Add tests for block/allow-lists

* Fix "No language model is associated with" issue

This was appearing because the models which are blocked were not
returned (correctly!) but the previous validation logic did not
know that sometimes models may be missing for a valid reason even
if there are existing settings for these.

* Add docs for allow listing and block listing providers

* Updated docs

* Added an intro block to docs

* Updated the docs

---------

Co-authored-by: Piyush Jain <piyushjain@duck.com>

* Publish 2.4.0

SHA256 hashes:

jupyter-ai-core-2.4.0.tgz: 04773e2b888853cd1c27785ac3c8434226e9a279a2fd253962cb20e5e9f72c1d

jupyter_ai-2.4.0-py3-none-any.whl: a5880cc108a107c746935d7eaa2513dffa29d2812e6628fd22a972a97aba4e2a

jupyter_ai-2.4.0.tar.gz: 0d065b18f4985fb726010e76d9c6059932e21327ea2951ccaa18b6e7b5189240

jupyter_ai_magics-2.4.0-py3-none-any.whl: 585bd960ac5c254e28ea165db840276883155a0a720720aa850e3272edc2001e

jupyter_ai_magics-2.4.0.tar.gz: 2cdfb1e084aad46cdbbfb4eed64b4e7abc96ad7fde31da2ddb6899225dfa0684

* Complete autocomplete

* Animations now also exist on automatic requests

* Remove DEVELOP.md

* Added toggle for selecting mock tests

* Make the code neater

---------

Co-authored-by: Andrii Ieroshenko <aieroshe@amazon.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Piyush Jain <piyushjain@duck.com>
Co-authored-by: dlqqq <dlqqq@users.noreply.github.com>
Co-authored-by: cjq <1401875340@qq.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: 3coins <3coins@users.noreply.github.com>
  • Loading branch information
8 people authored Oct 31, 2023
1 parent d290932 commit b5a0ada
Show file tree
Hide file tree
Showing 51 changed files with 27,415 additions and 2,237 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: E2E Tests

# suppress warning raised by https://github.com/jupyter/jupyter_core/pull/292
env:
JUPYTER_PLATFORM_DIRS: '1'

on:
push:
branches: main
pull_request:
branches: '*'

jobs:
e2e-tests:
name: Linux
runs-on: ubuntu-latest

env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install extension dependencies and build the extension
run: ./scripts/install.sh

- name: Install ui-tests dependencies
working-directory: packages/jupyter-ai/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install

- name: Set up browser cache
uses: actions/cache@v2
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('packages/jupyter-ai/ui-tests/yarn.lock') }}

- name: Install browser
working-directory: packages/jupyter-ai/ui-tests
run: jlpm install-chromium

- name: Execute e2e tests
working-directory: packages/jupyter-ai/ui-tests
run: jlpm test

- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v2
with:
name: jupyter-ai-playwright-tests-linux
path: |
packages/jupyter-ai/ui-tests/test-results
packages/jupyter-ai/ui-tests/playwright-report
52 changes: 52 additions & 0 deletions .github/workflows/update-snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Update Playwright Snapshots

on:
issue_comment:
types: [created, edited]
workflow_dispatch:
inputs:
number:
description: 'PR number'
required: true

permissions:
contents: write
pull-requests: write

jobs:
update-snapshots:
if: ${{ github.event.inputs || (github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots')) }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure git to use https
run: git config --global hub.protocol https

- name: Checkout the branch from the PR that triggered the job
run: hub pr checkout ${{ github.event.inputs.number || github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install extension dependencies and build the extension
run: ./scripts/install.sh

- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
start_server_script: 'null'
test_folder: packages/jupyter-ai/ui-tests
npm_client: jlpm

- name: Comment back on the PR
run: |
hub api repos/${{ github.repository }}/issues/${{ github.event.inputs.number || github.event.issue.number }}/comments --raw-field 'body=Playwright snapshots updated.'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: check-case-conflict
Expand All @@ -18,7 +18,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black

Expand All @@ -30,7 +30,7 @@ repos:
files: \.py$

- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]
Expand All @@ -48,7 +48,7 @@ repos:
stages: [manual]

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.23.3
rev: 0.27.0
hooks:
- id: check-jsonschema
name: "Check GitHub Workflows"
Expand Down
68 changes: 66 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,72 @@

<!-- <START NEW CHANGELOG ENTRY> -->

## 2.4.0

([Full Changelog](https://github.com/jupyterlab/jupyter-ai/compare/@jupyter-ai/core@2.3.0...92dab10608ea090b6bd87ca5ffe9ccff7a15b449))

Hey Jupyternauts! We're excited to announce the 2.4.0 release of Jupyter AI, which includes better support for Bedrock Anthropic models. Thanks to [@krassowski](https://github.com/krassowski) for providing a new feature in Jupyter AI that let's admins specify allowlists and blocklists to filter the list of providers available in the chat settings panel.

### Enhancements made

- Allow to define block and allow lists for providers [#415](https://github.com/jupyterlab/jupyter-ai/pull/415) ([@krassowski](https://github.com/krassowski))

### Bugs fixed

- Refactor generate for better stability with all providers/models [#407](https://github.com/jupyterlab/jupyter-ai/pull/407) ([@3coins](https://github.com/3coins))

### Maintenance and upkeep improvements

### Contributors to this release

([GitHub contributors page for this release](https://github.com/jupyterlab/jupyter-ai/graphs/contributors?from=2023-10-09&to=2023-10-24&type=c))

[@3coins](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3A3coins+updated%3A2023-10-09..2023-10-24&type=Issues) | [@krassowski](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Akrassowski+updated%3A2023-10-09..2023-10-24&type=Issues) | [@pre-commit-ci](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Apre-commit-ci+updated%3A2023-10-09..2023-10-24&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 2.3.0

([Full Changelog](https://github.com/jupyterlab/jupyter-ai/compare/@jupyter-ai/core@2.2.0...7f854007263f1a9393e41611028d7cc57313c577))

Hey Jupyternauts! We're excited to announce the 2.3.0 release of Jupyter AI, which includes better support for Anthropic models and integration with Amazon Bedrock.

There is also a significant change to how Jupyter AI settings are handled (see #353). The most significant changes are:

1. **API key values can no longer be read from the client.** This was taken as a security measure to prevent accidental leakage of keys. You can still update existing API keys if you do decide to change your key in the future.
1. **The settings can not be updated if they were updated by somebody else after you opened the settings panel.** This prevents different users connecting to the same server from clobbering updates from each other.
1. **There is now a much better UI for updating and deleting API keys.** We hope you enjoy it.

Updating to 2.3.0 shouldn't require any changes on your end. However, if you notice an error, please submit a bug report with the server logs emitted in the terminal from the `jupyter lab` process. Renaming the config file `$JUPYTER_DATA_DIR/jupyter_ai/config.json` to some other name and then restarting `jupyter lab` may fix the issue if it is a result of the new config changes.

### Enhancements made

- Adds chat anthropic provider, new models [#391](https://github.com/jupyterlab/jupyter-ai/pull/391) ([@3coins](https://github.com/3coins))
- Adds help text for registry model providers in chat UI settings [#373](https://github.com/jupyterlab/jupyter-ai/pull/373) ([@JasonWeill](https://github.com/JasonWeill))
- jupyter_ai and jupyter_ai_magics version match [#367](https://github.com/jupyterlab/jupyter-ai/pull/367) ([@JasonWeill](https://github.com/JasonWeill))
- Config V2 [#353](https://github.com/jupyterlab/jupyter-ai/pull/353) ([@dlqqq](https://github.com/dlqqq))
- Add E2E tests [#350](https://github.com/jupyterlab/jupyter-ai/pull/350) ([@andrii-i](https://github.com/andrii-i))

### Bugs fixed

- Upgraded LangChain, fixed prompts for Bedrock [#401](https://github.com/jupyterlab/jupyter-ai/pull/401) ([@3coins](https://github.com/3coins))
- Adds chat anthropic provider, new models [#391](https://github.com/jupyterlab/jupyter-ai/pull/391) ([@3coins](https://github.com/3coins))

### Maintenance and upkeep improvements

- Upgraded LangChain, fixed prompts for Bedrock [#401](https://github.com/jupyterlab/jupyter-ai/pull/401) ([@3coins](https://github.com/3coins))
- Add E2E tests [#350](https://github.com/jupyterlab/jupyter-ai/pull/350) ([@andrii-i](https://github.com/andrii-i))

### Documentation improvements

- jupyter_ai and jupyter_ai_magics version match [#367](https://github.com/jupyterlab/jupyter-ai/pull/367) ([@JasonWeill](https://github.com/JasonWeill))

### Contributors to this release

([GitHub contributors page for this release](https://github.com/jupyterlab/jupyter-ai/graphs/contributors?from=2023-09-05&to=2023-10-09&type=c))

[@3coins](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3A3coins+updated%3A2023-09-05..2023-10-09&type=Issues) | [@andrii-i](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Aandrii-i+updated%3A2023-09-05..2023-10-09&type=Issues) | [@dlqqq](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Adlqqq+updated%3A2023-09-05..2023-10-09&type=Issues) | [@JasonWeill](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3AJasonWeill+updated%3A2023-09-05..2023-10-09&type=Issues) | [@krassowski](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Akrassowski+updated%3A2023-09-05..2023-10-09&type=Issues)

## 2.2.0

([Full Changelog](https://github.com/jupyterlab/jupyter-ai/compare/@jupyter-ai/core@2.1.0...56c1f518afd09d0d09a43221f0767aa961e9430f))
Expand Down Expand Up @@ -32,8 +98,6 @@

[@3coins](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3A3coins+updated%3A2023-08-15..2023-09-05&type=Issues) | [@andrii-i](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Aandrii-i+updated%3A2023-08-15..2023-09-05&type=Issues) | [@JasonWeill](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3AJasonWeill+updated%3A2023-08-15..2023-09-05&type=Issues) | [@krassowski](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Akrassowski+updated%3A2023-08-15..2023-09-05&type=Issues) | [@michaelchia](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Amichaelchia+updated%3A2023-08-15..2023-09-05&type=Issues) | [@minrk](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Aminrk+updated%3A2023-08-15..2023-09-05&type=Issues) | [@welcome](https://github.com/search?q=repo%3Ajupyterlab%2Fjupyter-ai+involves%3Awelcome+updated%3A2023-08-15..2023-09-05&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 2.1.0

([Full Changelog](https://github.com/jupyterlab/jupyter-ai/compare/@jupyter-ai/core@2.0.1...c689c6c0cce5212238943ec2ff1559f6ad2f63d5))
Expand Down
35 changes: 35 additions & 0 deletions docs/source/contributors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,38 @@ To uninstall your Jupyter AI development environment, deactivate and remove the
conda deactivate
conda env remove -n jupyter-ai
```

## Testing

### Integration / E2E tests

This extension uses Playwright for the integration / E2E tests (user-level tests).
More precisely, the JupyterLab helper
[Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to
test the extension in JupyterLab.

Install test dependencies (needed only once):

```sh
cd ./packages/jupyter-ai/ui-tests/
jlpm install
jlpm playwright install
```

Tests involve snapshot comparisons against a reference snapshots generated by the Github CI. If you are using an OS other than Linux, you will need to generate local snapshots before running the tests locally for the first time. To do this, execute the command:

```sh
cd ./packages/jupyter-ai/ui-tests/
jlpm test:update
```

To execute tests, run:

```sh
cd ./packages/jupyter-ai/ui-tests/
jlpm test
```

You can find more information in the
[ui-tests](https://github.com/jupyterlab/jupyter-ai/tree/main/packages/jupyter-ai/ui-tests)
README.
35 changes: 35 additions & 0 deletions docs/source/users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ Jupyter AI supports the following model providers:
|---------------------|----------------------|----------------------------|---------------------------------|
| AI21 | `ai21` | `AI21_API_KEY` | `ai21` |
| Anthropic | `anthropic` | `ANTHROPIC_API_KEY` | `anthropic` |
| Anthropic (chat) | `anthropic-chat` | `ANTHROPIC_API_KEY` | `anthropic` |
| Bedrock | `amazon-bedrock` | N/A | `boto3` |
| Bedrock (chat) | `amazon-bedrock-chat`| N/A | `boto3` |
| Cohere | `cohere` | `COHERE_API_KEY` | `cohere` |
| Hugging Face Hub | `huggingface_hub` | `HUGGINGFACEHUB_API_TOKEN` | `huggingface_hub`, `ipywidgets`, `pillow` |
| OpenAI | `openai` | `OPENAI_API_KEY` | `openai` |
Expand Down Expand Up @@ -464,6 +466,9 @@ We currently support the following language model providers:

- `ai21`
- `anthropic`
- `anthropic-chat`
- `bedrock`
- `bedrock-chat`
- `cohere`
- `huggingface_hub`
- `openai`
Expand Down Expand Up @@ -783,3 +788,33 @@ Max prompt tokens:
Max response tokens:

- Set 'Max Response Tokens' judiciously; a higher value can slow response times, and since we don't support streaming, you'll await the entire response.

## Configuration

You can specify an allowlist, to only allow only a certain list of providers, or a blocklist, to block some providers.

### Blocklisting providers
This configuration allows for blocking specific providers in the settings panel. This list takes precedence over the allowlist in the next section.

```
jupyter lab --AiExtension.blocked_providers=openai
```

To block more than one provider in the block-list, repeat the runtime configuration.

```
jupyter lab --AiExtension.blocked_providers=openai --AiExtension.blocked_providers=ai21
```

### Allowlisting providers
This configuration allows for filtering the list of providers in the settings panel to only an allowlisted set of providers.

```
jupyter lab --AiExtension.allowed_providers=openai
```

To allow more than one provider in the allowlist, repeat the runtime configuration.

```
jupyter lab --AiExtension.allowed_providers=openai --AiExtension.allowed_providers=ai21
```
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "2.2.0",
"version": "2.4.0",
"npmClient": "yarn",
"useNx": true
}
Loading

0 comments on commit b5a0ada

Please sign in to comment.