@jupyterlite/ai 0.11.0 → 0.11.1
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/chat-model-registry.d.ts +6 -1
- package/lib/chat-model-registry.js +12 -0
- package/lib/index.js +20 -13
- package/lib/tokens.d.ts +2 -0
- package/package.json +1 -1
- package/src/chat-model-registry.ts +14 -1
- package/src/index.ts +20 -12
- package/src/tokens.ts +2 -0
|
@@ -15,6 +15,11 @@ export declare class ChatModelRegistry implements IChatModelRegistry {
|
|
|
15
15
|
get(name: string): AIChatModel | undefined;
|
|
16
16
|
getAll(): AIChatModel[];
|
|
17
17
|
remove(name: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Getter/setter for the active cell manager.
|
|
20
|
+
*/
|
|
21
|
+
get activeCellManager(): ActiveCellManager | undefined;
|
|
22
|
+
set activeCellManager(manager: ActiveCellManager | undefined);
|
|
18
23
|
private _models;
|
|
19
24
|
private _docManager;
|
|
20
25
|
private _agentManagerFactory;
|
|
@@ -49,7 +54,7 @@ export declare namespace ChatModelRegistry {
|
|
|
49
54
|
/**
|
|
50
55
|
* The active cell manager.
|
|
51
56
|
*/
|
|
52
|
-
activeCellManager
|
|
57
|
+
activeCellManager?: ActiveCellManager | undefined;
|
|
53
58
|
/**
|
|
54
59
|
* The application language translation bundle.
|
|
55
60
|
*/
|
|
@@ -52,6 +52,9 @@ export class ChatModelRegistry {
|
|
|
52
52
|
add(model) {
|
|
53
53
|
if (!this._models.find(m => m.name === model.name)) {
|
|
54
54
|
this._models.push(model);
|
|
55
|
+
model.disposed.connect(() => {
|
|
56
|
+
this.remove(model.name);
|
|
57
|
+
});
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
get(name) {
|
|
@@ -66,6 +69,15 @@ export class ChatModelRegistry {
|
|
|
66
69
|
this._models.splice(index, 1);
|
|
67
70
|
}
|
|
68
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Getter/setter for the active cell manager.
|
|
74
|
+
*/
|
|
75
|
+
get activeCellManager() {
|
|
76
|
+
return this._activeCellManager;
|
|
77
|
+
}
|
|
78
|
+
set activeCellManager(manager) {
|
|
79
|
+
this._activeCellManager = manager;
|
|
80
|
+
}
|
|
69
81
|
_models = [];
|
|
70
82
|
_docManager;
|
|
71
83
|
_agentManagerFactory;
|
package/lib/index.js
CHANGED
|
@@ -105,20 +105,11 @@ const chatModelRegistry = {
|
|
|
105
105
|
description: 'Registry for the current chat model',
|
|
106
106
|
autoStart: true,
|
|
107
107
|
requires: [IAISettingsModel, IAgentManagerFactory, IDocumentManager],
|
|
108
|
-
optional: [IProviderRegistry,
|
|
108
|
+
optional: [IProviderRegistry, IToolRegistry, ITranslator],
|
|
109
109
|
provides: IChatModelRegistry,
|
|
110
|
-
activate: (app, settingsModel, agentManagerFactory, docManager, providerRegistry,
|
|
110
|
+
activate: (app, settingsModel, agentManagerFactory, docManager, providerRegistry, toolRegistry, translator) => {
|
|
111
111
|
const trans = (translator ?? nullTranslator).load('jupyterlite_ai');
|
|
112
|
-
// Create ActiveCellManager if notebook tracker is available
|
|
113
|
-
let activeCellManager;
|
|
114
|
-
if (notebookTracker) {
|
|
115
|
-
activeCellManager = new ActiveCellManager({
|
|
116
|
-
tracker: notebookTracker,
|
|
117
|
-
shell: app.shell
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
112
|
return new ChatModelRegistry({
|
|
121
|
-
activeCellManager,
|
|
122
113
|
settingsModel,
|
|
123
114
|
agentManagerFactory,
|
|
124
115
|
docManager,
|
|
@@ -141,8 +132,14 @@ const plugin = {
|
|
|
141
132
|
IChatModelRegistry,
|
|
142
133
|
IAISettingsModel
|
|
143
134
|
],
|
|
144
|
-
optional: [
|
|
145
|
-
|
|
135
|
+
optional: [
|
|
136
|
+
IThemeManager,
|
|
137
|
+
ILayoutRestorer,
|
|
138
|
+
ILabShell,
|
|
139
|
+
INotebookTracker,
|
|
140
|
+
ITranslator
|
|
141
|
+
],
|
|
142
|
+
activate: (app, rmRegistry, inputToolbarFactory, modelRegistry, settingsModel, themeManager, restorer, labShell, notebookTracker, translator) => {
|
|
146
143
|
const trans = (translator ?? nullTranslator).load('jupyterlite_ai');
|
|
147
144
|
// Create attachment opener registry to handle file attachments
|
|
148
145
|
const attachmentOpenerRegistry = new AttachmentOpenerRegistry();
|
|
@@ -152,6 +149,16 @@ const plugin = {
|
|
|
152
149
|
attachmentOpenerRegistry.set('notebook', attachment => {
|
|
153
150
|
app.commands.execute('docmanager:open', { path: attachment.value });
|
|
154
151
|
});
|
|
152
|
+
// Create ActiveCellManager if notebook tracker is available, and add it to the
|
|
153
|
+
// model registry.
|
|
154
|
+
let activeCellManager;
|
|
155
|
+
if (notebookTracker) {
|
|
156
|
+
activeCellManager = new ActiveCellManager({
|
|
157
|
+
tracker: notebookTracker,
|
|
158
|
+
shell: app.shell
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
modelRegistry.activeCellManager = activeCellManager;
|
|
155
162
|
// Create chat panel with drag/drop functionality
|
|
156
163
|
const chatPanel = new MultiChatPanel({
|
|
157
164
|
rmRegistry,
|
package/lib/tokens.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActiveCellManager } from '@jupyter/chat';
|
|
1
2
|
import { Token } from '@lumino/coreutils';
|
|
2
3
|
import { ISignal } from '@lumino/signaling';
|
|
3
4
|
import type { Tool, LanguageModel } from 'ai';
|
|
@@ -194,6 +195,7 @@ export interface IChatModelRegistry {
|
|
|
194
195
|
getAll(): AIChatModel[];
|
|
195
196
|
remove(name: string): void;
|
|
196
197
|
createModel(name?: string, activeProvider?: string, tokenUsage?: ITokenUsage): AIChatModel;
|
|
198
|
+
activeCellManager: ActiveCellManager | undefined;
|
|
197
199
|
}
|
|
198
200
|
export declare const IChatModelRegistry: Token<IChatModelRegistry>;
|
|
199
201
|
/**
|
package/package.json
CHANGED
|
@@ -75,6 +75,9 @@ export class ChatModelRegistry implements IChatModelRegistry {
|
|
|
75
75
|
add(model: AIChatModel): void {
|
|
76
76
|
if (!this._models.find(m => m.name === model.name)) {
|
|
77
77
|
this._models.push(model);
|
|
78
|
+
model.disposed.connect(() => {
|
|
79
|
+
this.remove(model.name);
|
|
80
|
+
});
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
@@ -93,6 +96,16 @@ export class ChatModelRegistry implements IChatModelRegistry {
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Getter/setter for the active cell manager.
|
|
101
|
+
*/
|
|
102
|
+
get activeCellManager(): ActiveCellManager | undefined {
|
|
103
|
+
return this._activeCellManager;
|
|
104
|
+
}
|
|
105
|
+
set activeCellManager(manager: ActiveCellManager | undefined) {
|
|
106
|
+
this._activeCellManager = manager;
|
|
107
|
+
}
|
|
108
|
+
|
|
96
109
|
private _models: AIChatModel[] = [];
|
|
97
110
|
private _docManager: IDocumentManager;
|
|
98
111
|
private _agentManagerFactory: AgentManagerFactory;
|
|
@@ -128,7 +141,7 @@ export namespace ChatModelRegistry {
|
|
|
128
141
|
/**
|
|
129
142
|
* The active cell manager.
|
|
130
143
|
*/
|
|
131
|
-
activeCellManager
|
|
144
|
+
activeCellManager?: ActiveCellManager | undefined;
|
|
132
145
|
/**
|
|
133
146
|
* The application language translation bundle.
|
|
134
147
|
*/
|
package/src/index.ts
CHANGED
|
@@ -191,7 +191,7 @@ const chatModelRegistry: JupyterFrontEndPlugin<IChatModelRegistry> = {
|
|
|
191
191
|
description: 'Registry for the current chat model',
|
|
192
192
|
autoStart: true,
|
|
193
193
|
requires: [IAISettingsModel, IAgentManagerFactory, IDocumentManager],
|
|
194
|
-
optional: [IProviderRegistry,
|
|
194
|
+
optional: [IProviderRegistry, IToolRegistry, ITranslator],
|
|
195
195
|
provides: IChatModelRegistry,
|
|
196
196
|
activate: (
|
|
197
197
|
app: JupyterFrontEnd,
|
|
@@ -199,22 +199,12 @@ const chatModelRegistry: JupyterFrontEndPlugin<IChatModelRegistry> = {
|
|
|
199
199
|
agentManagerFactory: AgentManagerFactory,
|
|
200
200
|
docManager: IDocumentManager,
|
|
201
201
|
providerRegistry?: IProviderRegistry,
|
|
202
|
-
notebookTracker?: INotebookTracker,
|
|
203
202
|
toolRegistry?: IToolRegistry,
|
|
204
203
|
translator?: ITranslator
|
|
205
204
|
): IChatModelRegistry => {
|
|
206
205
|
const trans = (translator ?? nullTranslator).load('jupyterlite_ai');
|
|
207
206
|
|
|
208
|
-
// Create ActiveCellManager if notebook tracker is available
|
|
209
|
-
let activeCellManager: ActiveCellManager | undefined;
|
|
210
|
-
if (notebookTracker) {
|
|
211
|
-
activeCellManager = new ActiveCellManager({
|
|
212
|
-
tracker: notebookTracker,
|
|
213
|
-
shell: app.shell
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
207
|
return new ChatModelRegistry({
|
|
217
|
-
activeCellManager,
|
|
218
208
|
settingsModel,
|
|
219
209
|
agentManagerFactory,
|
|
220
210
|
docManager,
|
|
@@ -238,7 +228,13 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
238
228
|
IChatModelRegistry,
|
|
239
229
|
IAISettingsModel
|
|
240
230
|
],
|
|
241
|
-
optional: [
|
|
231
|
+
optional: [
|
|
232
|
+
IThemeManager,
|
|
233
|
+
ILayoutRestorer,
|
|
234
|
+
ILabShell,
|
|
235
|
+
INotebookTracker,
|
|
236
|
+
ITranslator
|
|
237
|
+
],
|
|
242
238
|
activate: (
|
|
243
239
|
app: JupyterFrontEnd,
|
|
244
240
|
rmRegistry: IRenderMimeRegistry,
|
|
@@ -248,6 +244,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
248
244
|
themeManager?: IThemeManager,
|
|
249
245
|
restorer?: ILayoutRestorer,
|
|
250
246
|
labShell?: ILabShell,
|
|
247
|
+
notebookTracker?: INotebookTracker,
|
|
251
248
|
translator?: ITranslator
|
|
252
249
|
): void => {
|
|
253
250
|
const trans = (translator ?? nullTranslator).load('jupyterlite_ai');
|
|
@@ -261,6 +258,17 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
261
258
|
app.commands.execute('docmanager:open', { path: attachment.value });
|
|
262
259
|
});
|
|
263
260
|
|
|
261
|
+
// Create ActiveCellManager if notebook tracker is available, and add it to the
|
|
262
|
+
// model registry.
|
|
263
|
+
let activeCellManager: ActiveCellManager | undefined;
|
|
264
|
+
if (notebookTracker) {
|
|
265
|
+
activeCellManager = new ActiveCellManager({
|
|
266
|
+
tracker: notebookTracker,
|
|
267
|
+
shell: app.shell
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
modelRegistry.activeCellManager = activeCellManager;
|
|
271
|
+
|
|
264
272
|
// Create chat panel with drag/drop functionality
|
|
265
273
|
const chatPanel = new MultiChatPanel({
|
|
266
274
|
rmRegistry,
|
package/src/tokens.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActiveCellManager } from '@jupyter/chat';
|
|
1
2
|
import { Token } from '@lumino/coreutils';
|
|
2
3
|
import { ISignal } from '@lumino/signaling';
|
|
3
4
|
import type { Tool, LanguageModel } from 'ai';
|
|
@@ -249,6 +250,7 @@ export interface IChatModelRegistry {
|
|
|
249
250
|
activeProvider?: string,
|
|
250
251
|
tokenUsage?: ITokenUsage
|
|
251
252
|
): AIChatModel;
|
|
253
|
+
activeCellManager: ActiveCellManager | undefined;
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
export const IChatModelRegistry = new Token<IChatModelRegistry>(
|