@oceanum/oceanumlab 4.6.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/DatameshWidget.d.ts +7 -1
- package/lib/DatameshWidget.js +110 -43
- package/lib/aiBackend.d.ts +66 -0
- package/lib/aiBackend.js +101 -0
- package/lib/chatRouter.d.ts +5 -1
- package/lib/chatRouter.js +27 -9
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +1 -1
- package/lib/datameshUiUrl.js +2 -10
- package/lib/httpUrl.d.ts +9 -0
- package/lib/httpUrl.js +20 -0
- package/lib/index.js +15 -2
- package/package.json +1 -1
- package/schema/datamesh-connect.json +6 -0
- package/src/DatameshWidget.tsx +184 -54
- package/src/__tests__/DatameshWidget.spec.tsx +380 -0
- package/src/__tests__/aiBackend.spec.ts +272 -0
- package/src/__tests__/chatRouter.spec.ts +259 -17
- package/src/aiBackend.ts +150 -0
- package/src/chatRouter.ts +36 -8
- package/src/constants.ts +1 -1
- package/src/datameshUiUrl.ts +2 -9
- package/src/httpUrl.ts +23 -0
- package/src/index.ts +19 -2
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { ICommandPalette, Notification } from '@jupyterlab/apputils';
|
|
8
8
|
import { LabIcon } from '@jupyterlab/ui-components';
|
|
9
9
|
import { find } from '@lumino/algorithm';
|
|
10
|
+
import { Signal } from '@lumino/signaling';
|
|
10
11
|
import { Widget } from '@lumino/widgets';
|
|
11
12
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
12
13
|
import { IStateDB } from '@jupyterlab/statedb';
|
|
@@ -21,7 +22,11 @@ import { snapshotFromIpynb, snapshotOf } from './notebookContext';
|
|
|
21
22
|
import { notebookHost } from './notebookHost';
|
|
22
23
|
import { KernelHandoff } from './kernelHandoff';
|
|
23
24
|
import { runChatLoop, STOPPED } from './aiLoop';
|
|
24
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
DATAMESH_UI_SERVICE,
|
|
27
|
+
MAX_OBSERVE_ROUNDS,
|
|
28
|
+
OCEANUM_AI_BACKEND_URL
|
|
29
|
+
} from './constants';
|
|
25
30
|
|
|
26
31
|
import '../style/index.css';
|
|
27
32
|
|
|
@@ -59,6 +64,12 @@ export const datamesh_connect_extension: JupyterFrontEndPlugin<void> = {
|
|
|
59
64
|
|
|
60
65
|
// The `datameshUiUrl` setting; the default until the settings load.
|
|
61
66
|
let datameshUiUrl = DATAMESH_UI_SERVICE;
|
|
67
|
+
// The `aiBackendUrl` and `datameshToken` settings for the AI chat; the
|
|
68
|
+
// defaults until the settings load.
|
|
69
|
+
let aiBackendUrl = OCEANUM_AI_BACKEND_URL;
|
|
70
|
+
let datameshTokenSetting = '';
|
|
71
|
+
// Tells the sidebar the settings above have changed.
|
|
72
|
+
const settingsChanged = new Signal<JupyterFrontEnd, void>(app);
|
|
62
73
|
|
|
63
74
|
const findDatameshUI = (): DatameshUI | undefined =>
|
|
64
75
|
find(
|
|
@@ -77,12 +88,15 @@ export const datamesh_connect_extension: JupyterFrontEndPlugin<void> = {
|
|
|
77
88
|
}).then(res => console.log(res));
|
|
78
89
|
}
|
|
79
90
|
window.injectToken = set.get('injectToken').user as boolean;
|
|
91
|
+
aiBackendUrl = set.get('aiBackendUrl').composite as string;
|
|
92
|
+
datameshTokenSetting = set.get('datameshToken').composite as string;
|
|
80
93
|
// An open Datamesh UI panel follows a change of address.
|
|
81
94
|
datameshUiUrl = set.get('datameshUiUrl').composite as string;
|
|
82
95
|
const datameshUI = findDatameshUI();
|
|
83
96
|
if (datameshUI) {
|
|
84
97
|
datameshUI.url = datameshUiUrl;
|
|
85
98
|
}
|
|
99
|
+
settingsChanged.emit();
|
|
86
100
|
};
|
|
87
101
|
//Try to get the datamesh token from the envars
|
|
88
102
|
|
|
@@ -127,6 +141,9 @@ export const datamesh_connect_extension: JupyterFrontEndPlugin<void> = {
|
|
|
127
141
|
openDatameshUI: openDatameshUI,
|
|
128
142
|
datameshUiUrl: () => datameshUiUrl,
|
|
129
143
|
datameshUiFrame: () => findDatameshUI()?.frame ?? null,
|
|
144
|
+
datameshToken: () => datameshTokenSetting,
|
|
145
|
+
aiBackendUrl: () => aiBackendUrl,
|
|
146
|
+
settingsChanged,
|
|
130
147
|
commands: app.commands,
|
|
131
148
|
getCurrentWidget
|
|
132
149
|
});
|
|
@@ -180,7 +197,7 @@ export const oceanum_ai_extension: JupyterFrontEndPlugin<void> = {
|
|
|
180
197
|
// The panel the current request read its selected cell from, if the
|
|
181
198
|
// notebook was open: a code answer may replace that cell only there.
|
|
182
199
|
let readFrom: NotebookPanel | null = null;
|
|
183
|
-
const router = new ChatRouter(settings, async () => {
|
|
200
|
+
const router = new ChatRouter(settings, app.commands, async () => {
|
|
184
201
|
const open = await pin.current();
|
|
185
202
|
readFrom = open;
|
|
186
203
|
if (open) {
|