Skip to content

Commit b3bd346

Browse files
authored
Add existing chat commands (#1)
* WIP: migrate chat command frontend plugins to this repo * implement backend handling of /refresh-personas * update .gitignore * reset version to 0.0.1a0 * fix lint * reset version to 0.0.0 * bump to python v3.10 * patch the build dependency causing check-release to fail * try something * set virtualenv version in bump-version script directly * add before-bump-version hook * skip integration tests for now
1 parent e7c59bb commit b3bd346

File tree

14 files changed

+1196
-182
lines changed

14 files changed

+1196
-182
lines changed

.github/workflows/build.yml

Lines changed: 131 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -15,143 +15,143 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Base Setup
22-
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
23-
24-
- name: Install dependencies
25-
run: python -m pip install -U "jupyterlab>=4.0.0,<5"
26-
27-
- name: Lint the extension
28-
run: |
29-
set -eux
30-
jlpm
31-
jlpm run lint:check
32-
33-
- name: Test the extension
34-
run: |
35-
set -eux
36-
jlpm run test
37-
38-
- name: Build the extension
39-
run: |
40-
set -eux
41-
python -m pip install .[test]
42-
43-
pytest -vv -r ap --cov jupyter_ai_chat_commands
44-
jupyter server extension list
45-
jupyter server extension list 2>&1 | grep -ie "jupyter_ai_chat_commands.*OK"
46-
47-
jupyter labextension list
48-
jupyter labextension list 2>&1 | grep -ie "@jupyter-ai/chat-commands.*OK"
49-
python -m jupyterlab.browser_check
50-
51-
- name: Package the extension
52-
run: |
53-
set -eux
54-
55-
pip install build
56-
python -m build
57-
pip uninstall -y "jupyter_ai_chat_commands" jupyterlab
58-
59-
- name: Upload extension packages
60-
uses: actions/upload-artifact@v4
61-
with:
62-
name: extension-artifacts
63-
path: dist/jupyter_ai_chat_commands*
64-
if-no-files-found: error
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Base Setup
22+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
23+
24+
- name: Install dependencies
25+
run: python -m pip install -U "jupyterlab>=4.0.0,<5"
26+
27+
- name: Lint the extension
28+
run: |
29+
set -eux
30+
jlpm
31+
jlpm run lint:check
32+
33+
- name: Test the extension
34+
run: |
35+
set -eux
36+
jlpm run test
37+
38+
- name: Build the extension
39+
run: |
40+
set -eux
41+
python -m pip install .[test]
42+
43+
pytest -vv -r ap --cov jupyter_ai_chat_commands
44+
jupyter server extension list
45+
jupyter server extension list 2>&1 | grep -ie "jupyter_ai_chat_commands.*OK"
46+
47+
jupyter labextension list
48+
jupyter labextension list 2>&1 | grep -ie "@jupyter-ai/chat-commands.*OK"
49+
python -m jupyterlab.browser_check
50+
51+
- name: Package the extension
52+
run: |
53+
set -eux
54+
55+
pip install build
56+
python -m build
57+
pip uninstall -y "jupyter_ai_chat_commands" jupyterlab
58+
59+
- name: Upload extension packages
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: extension-artifacts
63+
path: dist/jupyter_ai_chat_commands*
64+
if-no-files-found: error
6565

6666
test_isolated:
6767
needs: build
6868
runs-on: ubuntu-latest
6969

7070
steps:
71-
- name: Install Python
72-
uses: actions/setup-python@v5
73-
with:
74-
python-version: '3.9'
75-
architecture: 'x64'
76-
- uses: actions/download-artifact@v4
77-
with:
78-
name: extension-artifacts
79-
- name: Install and Test
80-
run: |
81-
set -eux
82-
# Remove NodeJS, twice to take care of system and locally installed node versions.
83-
sudo rm -rf $(which node)
84-
sudo rm -rf $(which node)
85-
86-
pip install "jupyterlab>=4.0.0,<5" jupyter_ai_chat_commands*.whl
87-
88-
89-
jupyter server extension list
90-
jupyter server extension list 2>&1 | grep -ie "jupyter_ai_chat_commands.*OK"
91-
92-
jupyter labextension list
93-
jupyter labextension list 2>&1 | grep -ie "@jupyter-ai/chat-commands.*OK"
94-
python -m jupyterlab.browser_check --no-browser-test
95-
96-
integration-tests:
97-
name: Integration tests
98-
needs: build
99-
runs-on: ubuntu-latest
100-
101-
env:
102-
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
103-
104-
steps:
105-
- name: Checkout
106-
uses: actions/checkout@v4
107-
108-
- name: Base Setup
109-
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
110-
111-
- name: Download extension package
112-
uses: actions/download-artifact@v4
113-
with:
114-
name: extension-artifacts
115-
116-
- name: Install the extension
117-
run: |
118-
set -eux
119-
python -m pip install "jupyterlab>=4.0.0,<5" jupyter_ai_chat_commands*.whl
120-
121-
- name: Install dependencies
122-
working-directory: ui-tests
123-
env:
124-
YARN_ENABLE_IMMUTABLE_INSTALLS: 0
125-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
126-
run: jlpm install
127-
128-
- name: Set up browser cache
129-
uses: actions/cache@v4
130-
with:
131-
path: |
132-
${{ github.workspace }}/pw-browsers
133-
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
134-
135-
- name: Install browser
136-
run: |
137-
set -eux
138-
jlpm playwright install-deps
139-
jlpm playwright install chromium
140-
working-directory: ui-tests
141-
142-
- name: Execute integration tests
143-
working-directory: ui-tests
144-
run: |
145-
jlpm playwright test
146-
147-
- name: Upload Playwright Test report
148-
if: always()
149-
uses: actions/upload-artifact@v4
150-
with:
151-
name: jupyter_ai_chat_commands-playwright-tests
152-
path: |
153-
ui-tests/test-results
154-
ui-tests/playwright-report
71+
- name: Install Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: '3.10'
75+
architecture: 'x64'
76+
- uses: actions/download-artifact@v4
77+
with:
78+
name: extension-artifacts
79+
- name: Install and Test
80+
run: |
81+
set -eux
82+
# Remove NodeJS, twice to take care of system and locally installed node versions.
83+
sudo rm -rf $(which node)
84+
sudo rm -rf $(which node)
85+
86+
pip install "jupyterlab>=4.0.0,<5" jupyter_ai_chat_commands*.whl
87+
88+
89+
jupyter server extension list
90+
jupyter server extension list 2>&1 | grep -ie "jupyter_ai_chat_commands.*OK"
91+
92+
jupyter labextension list
93+
jupyter labextension list 2>&1 | grep -ie "@jupyter-ai/chat-commands.*OK"
94+
python -m jupyterlab.browser_check --no-browser-test
95+
96+
# integration-tests:
97+
# name: Integration tests
98+
# needs: build
99+
# runs-on: ubuntu-latest
100+
101+
# env:
102+
# PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
103+
104+
# steps:
105+
# - name: Checkout
106+
# uses: actions/checkout@v4
107+
108+
# - name: Base Setup
109+
# uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
110+
111+
# - name: Download extension package
112+
# uses: actions/download-artifact@v4
113+
# with:
114+
# name: extension-artifacts
115+
116+
# - name: Install the extension
117+
# run: |
118+
# set -eux
119+
# python -m pip install "jupyterlab>=4.0.0,<5" jupyter_ai_chat_commands*.whl
120+
121+
# - name: Install dependencies
122+
# working-directory: ui-tests
123+
# env:
124+
# YARN_ENABLE_IMMUTABLE_INSTALLS: 0
125+
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
126+
# run: jlpm install
127+
128+
# - name: Set up browser cache
129+
# uses: actions/cache@v4
130+
# with:
131+
# path: |
132+
# ${{ github.workspace }}/pw-browsers
133+
# key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
134+
135+
# - name: Install browser
136+
# run: |
137+
# set -eux
138+
# jlpm playwright install-deps
139+
# jlpm playwright install chromium
140+
# working-directory: ui-tests
141+
142+
# - name: Execute integration tests
143+
# working-directory: ui-tests
144+
# run: |
145+
# jlpm playwright test
146+
147+
# - name: Upload Playwright Test report
148+
# if: always()
149+
# uses: actions/upload-artifact@v4
150+
# with:
151+
# name: jupyter_ai_chat_commands-playwright-tests
152+
# path: |
153+
# ui-tests/test-results
154+
# ui-tests/playwright-report
155155

156156
check_links:
157157
name: Check Links

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,6 @@ dmypy.json
123123

124124
# Yarn cache
125125
.yarn/
126+
127+
*.chat
128+
.jupyter_ystore.db

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ This extension is composed of a Python package named `jupyter_ai_chat_commands`
88
for the server extension and a NPM package named `@jupyter-ai/chat-commands`
99
for the frontend extension.
1010

11+
This package provides 2 commands:
12+
13+
- `@file:<path>`: Add a file as an attachment to a message.
14+
15+
- `/refresh-personas`: Reload local personas defined in `.jupyter/personas`.
16+
1117
## QUICK START
1218

1319
Everything that follows after this section was from the extension template. We

jupyter_ai_chat_commands/__init__.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import warnings
88
warnings.warn("Importing 'jupyter_ai_chat_commands' outside a proper installation.")
99
__version__ = "dev"
10-
from .handlers import setup_handlers
10+
from .extension_app import JaiChatCommandsExtension
1111

1212

1313
def _jupyter_labextension_paths():
@@ -19,18 +19,7 @@ def _jupyter_labextension_paths():
1919

2020
def _jupyter_server_extension_points():
2121
return [{
22-
"module": "jupyter_ai_chat_commands"
22+
"module": "jupyter_ai_chat_commands",
23+
"app": JaiChatCommandsExtension
2324
}]
2425

25-
26-
def _load_jupyter_server_extension(server_app):
27-
"""Registers the API handler to receive HTTP requests from the frontend extension.
28-
29-
Parameters
30-
----------
31-
server_app: jupyterlab.labapp.LabApp
32-
JupyterLab application instance
33-
"""
34-
setup_handlers(server_app.web_app)
35-
name = "jupyter_ai_chat_commands"
36-
server_app.log.info(f"Registered {name} server extension")

0 commit comments

Comments
 (0)