Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 15d6e52

Browse files
committed
First version of a chat UI package, based on jupyter-ai chat UI
1 parent 7807932 commit 15d6e52

38 files changed

+2560
-433
lines changed

.copier-answers.yml

-19
This file was deleted.

README.md

+8-51
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,30 @@
33
[![Github Actions Status](https://github.com/QuantStack/jupyterlab-chat/workflows/Build/badge.svg)](https://github.com/QuantStack/jupyterlab-chat/actions/workflows/build.yml)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantStack/jupyterlab-chat/main?urlpath=lab)
44
A chat extension for Jupyterlab
55

6-
This extension is composed of a Python package named `jupyterlab_chat`
7-
for the server extension and a NPM package named `@jupyterlab/chat`
8-
for the frontend extension.
6+
This package is composed of a Python package named `jupyterlab_chat`
7+
for the server side and a NPM package named `@jupyterlab/chat`
8+
for the frontend side.
99

1010
## Requirements
1111

1212
- JupyterLab >= 4.0.0
1313

1414
## Install
1515

16-
To install the extension, execute:
16+
To install the package, execute:
1717

1818
```bash
1919
pip install jupyterlab_chat
2020
```
2121

2222
## Uninstall
2323

24-
To remove the extension, execute:
24+
To remove the package, execute:
2525

2626
```bash
2727
pip uninstall jupyterlab_chat
2828
```
2929

30-
## Troubleshoot
31-
32-
If you are seeing the frontend extension, but it is not working, check
33-
that the server extension is enabled:
34-
35-
```bash
36-
jupyter server extension list
37-
```
38-
39-
If the server extension is installed and enabled, but you are not seeing
40-
the frontend extension, check the frontend extension is installed:
41-
42-
```bash
43-
jupyter labextension list
44-
```
45-
4630
## Contributing
4731

4832
### Development install
@@ -58,44 +42,19 @@ The `jlpm` command is JupyterLab's pinned version of
5842
# Change directory to the jupyterlab_chat directory
5943
# Install package in development mode
6044
pip install -e ".[test]"
61-
# Link your development version of the extension with JupyterLab
62-
jupyter labextension develop . --overwrite
63-
# Server extension must be manually installed in develop mode
64-
jupyter server extension enable jupyterlab_chat
65-
# Rebuild extension Typescript source after making changes
45+
# Rebuild Typescript source after making changes
6646
jlpm build
6747
```
6848

69-
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.
70-
71-
```bash
72-
# Watch the source directory in one terminal, automatically rebuilding when needed
73-
jlpm watch
74-
# Run JupyterLab in another terminal
75-
jupyter lab
76-
```
77-
78-
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).
79-
80-
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:
81-
82-
```bash
83-
jupyter lab build --minimize=False
84-
```
49+
By default, the `jlpm build` command generates the source maps for this package to make it easier to debug using the browser dev tools.
8550

8651
### Development uninstall
8752

8853
```bash
89-
# Server extension must be manually disabled in develop mode
90-
jupyter server extension disable jupyterlab_chat
9154
pip uninstall jupyterlab_chat
9255
```
9356

94-
In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
95-
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
96-
folder is located. Then you can remove the symlink named `@jupyterlab/chat` within that folder.
97-
98-
### Testing the extension
57+
### Testing the package
9958

10059
#### Server tests
10160

@@ -105,8 +64,6 @@ Install test dependencies (needed only once):
10564

10665
```sh
10766
pip install -e ".[test]"
108-
# Each time you install the Python package, you need to restore the front-end extension link
109-
jupyter labextension develop . --overwrite
11067
```
11168

11269
To execute them, run:

conftest.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
import pytest
22

33
pytest_plugins = ("pytest_jupyter.jupyter_server", )
4-
5-
6-
@pytest.fixture
7-
def jp_server_config(jp_server_config):
8-
return {"ServerApp": {"jpserver_extensions": {"jupyterlab_chat": True}}}

jupyter-config/server-config/jupyterlab_chat.json

-7
This file was deleted.

jupyterlab_chat/__init__.py

+1-26
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,5 @@
77
import warnings
88
warnings.warn("Importing 'jupyterlab_chat' outside a proper installation.")
99
__version__ = "dev"
10-
from .handlers import setup_handlers
1110

12-
13-
def _jupyter_labextension_paths():
14-
return [{
15-
"src": "labextension",
16-
"dest": "@jupyterlab/chat"
17-
}]
18-
19-
20-
def _jupyter_server_extension_points():
21-
return [{
22-
"module": "jupyterlab_chat"
23-
}]
24-
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 = "jupyterlab_chat"
36-
server_app.log.info(f"Registered {name} server extension")
11+
from .extension import ChatExtension
+1-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
import json
2-
3-
4-
async def test_get_example(jp_fetch):
5-
# When
6-
response = await jp_fetch("jupyterlab-chat", "get-example")
7-
8-
# Then
9-
assert response.code == 200
10-
payload = json.loads(response.body)
11-
assert payload == {
12-
"data": "This is /jupyterlab-chat/get-example endpoint!"
13-
}
1+
### TODO ####

0 commit comments

Comments
 (0)