@jupyterlite/ai 0.17.0 → 0.19.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/chat-commands/clear.d.ts +1 -0
- package/lib/chat-commands/index.d.ts +1 -0
- package/lib/chat-commands/skills.d.ts +2 -1
- package/lib/chat-model-handler.d.ts +4 -3
- package/lib/chat-model-handler.js +2 -1
- package/lib/chat-model.d.ts +148 -8
- package/lib/chat-model.js +368 -79
- package/lib/completion/completion-provider.d.ts +3 -1
- package/lib/completion/completion-provider.js +1 -2
- package/lib/completion/index.d.ts +1 -0
- package/lib/components/clear-button.d.ts +1 -0
- package/lib/components/clear-button.js +3 -4
- package/lib/components/completion-status.d.ts +1 -0
- package/lib/components/completion-status.js +5 -4
- package/lib/components/index.d.ts +1 -0
- package/lib/components/model-select.d.ts +1 -0
- package/lib/components/model-select.js +62 -67
- package/lib/components/save-button.d.ts +3 -2
- package/lib/components/save-button.js +4 -5
- package/lib/components/stop-button.d.ts +1 -0
- package/lib/components/stop-button.js +3 -4
- package/lib/components/tool-select.d.ts +3 -1
- package/lib/components/tool-select.js +47 -60
- package/lib/components/usage-display.d.ts +4 -2
- package/lib/components/usage-display.js +50 -61
- package/lib/diff-manager.d.ts +3 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +50 -59
- package/lib/models/settings-model.d.ts +3 -1
- package/lib/models/settings-model.js +1 -0
- package/lib/rendered-message-outputarea.d.ts +1 -0
- package/lib/tokens.d.ts +48 -597
- package/lib/tokens.js +2 -31
- package/lib/widgets/ai-settings.d.ts +3 -1
- package/lib/widgets/ai-settings.js +185 -344
- package/lib/widgets/main-area-chat.d.ts +3 -3
- package/lib/widgets/main-area-chat.js +2 -4
- package/lib/widgets/provider-config-dialog.d.ts +2 -1
- package/lib/widgets/provider-config-dialog.js +102 -167
- package/package.json +111 -258
- package/schema/settings-model.json +6 -0
- package/src/chat-commands/skills.ts +2 -2
- package/src/chat-model-handler.ts +10 -6
- package/src/chat-model.ts +488 -96
- package/src/completion/completion-provider.ts +6 -6
- package/src/components/clear-button.tsx +0 -2
- package/src/components/completion-status.tsx +2 -2
- package/src/components/model-select.tsx +1 -1
- package/src/components/save-button.tsx +3 -3
- package/src/components/stop-button.tsx +0 -2
- package/src/components/tool-select.tsx +10 -9
- package/src/components/usage-display.tsx +4 -2
- package/src/diff-manager.ts +4 -3
- package/src/index.ts +103 -107
- package/src/models/settings-model.ts +7 -6
- package/src/tokens.ts +54 -744
- package/src/widgets/ai-settings.tsx +40 -11
- package/src/widgets/main-area-chat.ts +5 -8
- package/src/widgets/provider-config-dialog.tsx +8 -8
- package/LICENSE +0 -30
- package/README.md +0 -49
- package/lib/agent.d.ts +0 -277
- package/lib/agent.js +0 -1116
- package/lib/icons.d.ts +0 -3
- package/lib/icons.js +0 -8
- package/lib/providers/built-in-providers.d.ts +0 -21
- package/lib/providers/built-in-providers.js +0 -233
- package/lib/providers/generated-context-windows.d.ts +0 -8
- package/lib/providers/generated-context-windows.js +0 -96
- package/lib/providers/model-info.d.ts +0 -3
- package/lib/providers/model-info.js +0 -58
- package/lib/providers/models.d.ts +0 -37
- package/lib/providers/models.js +0 -28
- package/lib/providers/provider-registry.d.ts +0 -49
- package/lib/providers/provider-registry.js +0 -72
- package/lib/providers/provider-tools.d.ts +0 -36
- package/lib/providers/provider-tools.js +0 -93
- package/lib/skills/index.d.ts +0 -4
- package/lib/skills/index.js +0 -7
- package/lib/skills/parse-skill.d.ts +0 -25
- package/lib/skills/parse-skill.js +0 -69
- package/lib/skills/skill-loader.d.ts +0 -25
- package/lib/skills/skill-loader.js +0 -133
- package/lib/skills/skill-registry.d.ts +0 -31
- package/lib/skills/skill-registry.js +0 -100
- package/lib/skills/types.d.ts +0 -29
- package/lib/skills/types.js +0 -5
- package/lib/tools/commands.d.ts +0 -11
- package/lib/tools/commands.js +0 -154
- package/lib/tools/skills.d.ts +0 -9
- package/lib/tools/skills.js +0 -73
- package/lib/tools/tool-registry.d.ts +0 -35
- package/lib/tools/tool-registry.js +0 -55
- package/lib/tools/web.d.ts +0 -8
- package/lib/tools/web.js +0 -196
- package/src/agent.ts +0 -1441
- package/src/icons.ts +0 -11
- package/src/providers/built-in-providers.ts +0 -241
- package/src/providers/generated-context-windows.ts +0 -102
- package/src/providers/model-info.ts +0 -88
- package/src/providers/models.ts +0 -76
- package/src/providers/provider-registry.ts +0 -88
- package/src/providers/provider-tools.ts +0 -179
- package/src/skills/index.ts +0 -14
- package/src/skills/parse-skill.ts +0 -91
- package/src/skills/skill-loader.ts +0 -175
- package/src/skills/skill-registry.ts +0 -137
- package/src/skills/types.ts +0 -37
- package/src/tools/commands.ts +0 -210
- package/src/tools/skills.ts +0 -84
- package/src/tools/tool-registry.ts +0 -63
- package/src/tools/web.ts +0 -238
- package/src/types.d.ts +0 -4
- package/style/icons/jupyternaut-lite.svg +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { ReactWidget, UseSignal } from '@jupyterlab/ui-components';
|
|
2
|
-
import React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* React component that displays usage information.
|
|
5
5
|
* Shows input/output token counts and optional estimated context usage.
|
|
@@ -21,69 +21,58 @@ export const UsageDisplay = ({ tokenUsageChanged, settingsModel, initialTokenUsa
|
|
|
21
21
|
borderRadius: '4px',
|
|
22
22
|
whiteSpace: 'nowrap'
|
|
23
23
|
};
|
|
24
|
-
return (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return (React.createElement(UseSignal, { signal: tokenUsageChanged, initialArgs: initialTokenUsage }, (_, tokenUsage) => {
|
|
32
|
-
if (!tokenUsage) {
|
|
24
|
+
return (_jsx(UseSignal, { signal: settingsModel.stateChanged, initialArgs: undefined, children: () => {
|
|
25
|
+
const config = settingsModel.config;
|
|
26
|
+
const showTokenUsage = config.showTokenUsage;
|
|
27
|
+
const showContextUsage = config.showContextUsage;
|
|
28
|
+
if (!showTokenUsage && !showContextUsage) {
|
|
33
29
|
return null;
|
|
34
30
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
tokenUsage.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
showTokenUsage && (React.createElement("span", { style: badgeStyle, title: trans.__('Token Usage - Sent: %1, Received: %2, Total: %3', tokenUsage.inputTokens.toLocaleString(), tokenUsage.outputTokens.toLocaleString(), total.toLocaleString()) },
|
|
63
|
-
React.createElement("span", { style: {
|
|
31
|
+
return (_jsx(UseSignal, { signal: tokenUsageChanged, initialArgs: initialTokenUsage, children: (_, tokenUsage) => {
|
|
32
|
+
if (!tokenUsage) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const total = tokenUsage.inputTokens + tokenUsage.outputTokens;
|
|
36
|
+
const hasKnownContextWindow = showContextUsage && tokenUsage.contextWindow !== undefined;
|
|
37
|
+
const contextUsagePercent = tokenUsage.lastRequestInputTokens !== undefined &&
|
|
38
|
+
tokenUsage.contextWindow !== undefined &&
|
|
39
|
+
tokenUsage.contextWindow > 0
|
|
40
|
+
? Math.max(0, Math.min(100, (tokenUsage.lastRequestInputTokens /
|
|
41
|
+
tokenUsage.contextWindow) *
|
|
42
|
+
100))
|
|
43
|
+
: undefined;
|
|
44
|
+
const hasContextEstimate = hasKnownContextWindow &&
|
|
45
|
+
contextUsagePercent !== undefined &&
|
|
46
|
+
tokenUsage.lastRequestInputTokens !== undefined;
|
|
47
|
+
const contextLabel = hasContextEstimate
|
|
48
|
+
? `${formatContextPercent(contextUsagePercent)}%`
|
|
49
|
+
: hasKnownContextWindow
|
|
50
|
+
? '0%'
|
|
51
|
+
: '?';
|
|
52
|
+
const contextTitle = hasContextEstimate
|
|
53
|
+
? trans.__('Context Usage (estimated): %1% (%2 / %3 tokens)', formatContextPercent(contextUsagePercent), tokenUsage.lastRequestInputTokens.toLocaleString(), tokenUsage.contextWindow.toLocaleString())
|
|
54
|
+
: hasKnownContextWindow
|
|
55
|
+
? trans.__('Context usage estimate will appear after the next request. Showing 0% until then. Context window: %1 tokens', tokenUsage.contextWindow.toLocaleString())
|
|
56
|
+
: trans.__('Context Usage unavailable. Configure a context window for the active provider/model to enable estimation.');
|
|
57
|
+
return (_jsxs("div", { style: {
|
|
64
58
|
display: 'flex',
|
|
65
59
|
alignItems: 'center',
|
|
66
|
-
gap: '
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} },
|
|
83
|
-
React.createElement("span", null, "ctx"),
|
|
84
|
-
React.createElement("span", null, contextLabel))))));
|
|
85
|
-
}));
|
|
86
|
-
}));
|
|
60
|
+
gap: '6px'
|
|
61
|
+
}, children: [showTokenUsage && (_jsxs("span", { style: badgeStyle, title: trans.__('Token Usage - Sent: %1, Received: %2, Total: %3', tokenUsage.inputTokens.toLocaleString(), tokenUsage.outputTokens.toLocaleString(), total.toLocaleString()), children: [_jsxs("span", { style: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
gap: '2px'
|
|
65
|
+
}, children: [_jsx("span", { children: "\u2191" }), _jsx("span", { children: tokenUsage.inputTokens.toLocaleString() })] }), _jsxs("span", { style: {
|
|
66
|
+
display: 'flex',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
gap: '2px'
|
|
69
|
+
}, children: [_jsx("span", { children: "\u2193" }), _jsx("span", { children: tokenUsage.outputTokens.toLocaleString() })] })] })), showContextUsage && (_jsx("span", { style: badgeStyle, title: contextTitle, children: _jsxs("span", { style: {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
gap: '2px'
|
|
73
|
+
}, children: [_jsx("span", { children: "ctx" }), _jsx("span", { children: contextLabel })] }) }))] }));
|
|
74
|
+
} }));
|
|
75
|
+
} }));
|
|
87
76
|
};
|
|
88
77
|
/**
|
|
89
78
|
* JupyterLab widget wrapper for the UsageDisplay component.
|
|
@@ -103,7 +92,7 @@ export class UsageWidget extends ReactWidget {
|
|
|
103
92
|
* @returns The UsageDisplay React element
|
|
104
93
|
*/
|
|
105
94
|
render() {
|
|
106
|
-
return
|
|
95
|
+
return _jsx(UsageDisplay, { ...this._options });
|
|
107
96
|
}
|
|
108
97
|
_options;
|
|
109
98
|
}
|
package/lib/diff-manager.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { IDiffManager, IShowCellDiffParams, IShowFileDiffParams } from '@jupyternaut/agent';
|
|
1
2
|
import { CommandRegistry } from '@lumino/commands';
|
|
2
|
-
import type { IAISettingsModel
|
|
3
|
+
import type { IAISettingsModel } from './tokens';
|
|
3
4
|
/**
|
|
4
5
|
* Implementation of the diff manager
|
|
5
6
|
*/
|
|
@@ -22,3 +23,4 @@ export declare class DiffManager implements IDiffManager {
|
|
|
22
23
|
private _commands;
|
|
23
24
|
private _settingsModel;
|
|
24
25
|
}
|
|
26
|
+
//# sourceMappingURL=diff-manager.d.ts.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IAgentManagerFactory, IDiffManager, IProviderRegistry, IToolRegistry, ISkillRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
3
|
import { IChatCommandRegistry, IChatTracker, IInputToolbarRegistryFactory } from '@jupyter/chat';
|
|
3
|
-
import {
|
|
4
|
+
import { IAISettingsModel, IChatModelHandler } from './tokens';
|
|
4
5
|
declare const _default: (JupyterFrontEndPlugin<IProviderRegistry> | JupyterFrontEndPlugin<void> | JupyterFrontEndPlugin<IChatCommandRegistry> | JupyterFrontEndPlugin<IChatModelHandler> | JupyterFrontEndPlugin<IChatTracker> | JupyterFrontEndPlugin<IAgentManagerFactory> | JupyterFrontEndPlugin<IAISettingsModel> | JupyterFrontEndPlugin<IDiffManager> | JupyterFrontEndPlugin<ISkillRegistry> | JupyterFrontEndPlugin<IToolRegistry> | JupyterFrontEndPlugin<IInputToolbarRegistryFactory>)[];
|
|
5
6
|
export default _default;
|
|
6
7
|
export * from './tokens';
|
|
7
|
-
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { anthropicProvider, createBrowserFetchTool, createDiscoverCommandsTool, createDiscoverSkillsTool, createExecuteCommandTool, createLoadSkillTool, genericProvider, googleProvider, loadSkillsFromPaths, mistralProvider, openaiProvider, AgentManagerFactory, IAgentManagerFactory, IDiffManager, IProviderRegistry, IToolRegistry, ISkillRegistry, ProviderRegistry, SECRETS_NAMESPACE, SkillRegistry, ToolRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { ILabShell, ILayoutRestorer } from '@jupyterlab/application';
|
|
2
3
|
import { ActiveCellManager, AttachmentOpenerRegistry, chatIcon, ChatCommandRegistry, ChatWidget, IChatCommandRegistry, IChatTracker, IInputToolbarRegistryFactory, InputToolbarRegistry, MultiChatPanel } from '@jupyter/chat';
|
|
3
4
|
import { ICommandPalette, IThemeManager, showDialog, showErrorMessage, WidgetTracker } from '@jupyterlab/apputils';
|
|
@@ -11,28 +12,20 @@ import { IStatusBar } from '@jupyterlab/statusbar';
|
|
|
11
12
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
12
13
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
13
14
|
import { fileUploadIcon, saveIcon, settingsIcon, Toolbar, ToolbarButton } from '@jupyterlab/ui-components';
|
|
14
|
-
import {
|
|
15
|
+
import { UUID } from '@lumino/coreutils';
|
|
15
16
|
import { DisposableSet } from '@lumino/disposable';
|
|
16
17
|
import { IComponentsRendererFactory } from 'jupyter-chat-components';
|
|
17
18
|
import { ISecretsManager, SecretsManager } from 'jupyter-secrets-manager';
|
|
18
|
-
import { AgentManagerFactory } from './agent';
|
|
19
19
|
import { RenderedMessageOutputAreaCompat } from './rendered-message-outputarea';
|
|
20
20
|
import { ClearCommandProvider } from './chat-commands/clear';
|
|
21
21
|
import { SkillsCommandProvider } from './chat-commands/skills';
|
|
22
|
-
import { ProviderRegistry } from './providers/provider-registry';
|
|
23
22
|
import { SaveComponentWidget } from './components/save-button';
|
|
24
23
|
import { ChatModelHandler } from './chat-model-handler';
|
|
25
|
-
import { CommandIds,
|
|
26
|
-
import { anthropicProvider, googleProvider, mistralProvider, openaiProvider, genericProvider } from './providers/built-in-providers';
|
|
24
|
+
import { CommandIds, IAISettingsModel, IChatModelHandler } from './tokens';
|
|
27
25
|
import { AICompletionProvider } from './completion';
|
|
28
26
|
import { clearItem, createModelSelectItem, createToolSelectItem, stopItem, CompletionStatusWidget, UsageWidget } from './components';
|
|
29
27
|
import { AISettingsModel } from './models/settings-model';
|
|
30
|
-
import { loadSkillsFromPaths, SkillRegistry } from './skills';
|
|
31
28
|
import { DiffManager } from './diff-manager';
|
|
32
|
-
import { ToolRegistry } from './tools/tool-registry';
|
|
33
|
-
import { createDiscoverCommandsTool, createExecuteCommandTool } from './tools/commands';
|
|
34
|
-
import { createDiscoverSkillsTool, createLoadSkillTool } from './tools/skills';
|
|
35
|
-
import { createBrowserFetchTool } from './tools/web';
|
|
36
29
|
import { AISettingsWidget } from './widgets/ai-settings';
|
|
37
30
|
import { MainAreaChat } from './widgets/main-area-chat';
|
|
38
31
|
var Private;
|
|
@@ -386,12 +379,10 @@ const plugin = {
|
|
|
386
379
|
// Check if AI is currently writing (streaming)
|
|
387
380
|
const aiWriting = writers.some(writer => writer.user.username === 'ai-assistant');
|
|
388
381
|
if (aiWriting) {
|
|
389
|
-
widget.inputToolbarRegistry?.hide('send');
|
|
390
382
|
widget.inputToolbarRegistry?.show('stop');
|
|
391
383
|
}
|
|
392
384
|
else {
|
|
393
385
|
widget.inputToolbarRegistry?.hide('stop');
|
|
394
|
-
widget.inputToolbarRegistry?.show('send');
|
|
395
386
|
}
|
|
396
387
|
}
|
|
397
388
|
model.writersChanged?.connect(writersChanged);
|
|
@@ -439,19 +430,48 @@ const plugin = {
|
|
|
439
430
|
});
|
|
440
431
|
registerCommands(app, rmRegistry, chatPanel, attachmentOpenerRegistry, inputToolbarFactory, settingsModel, chatCommandRegistry, tracker, modelHandler, trans, themeManager, labShell, palette, documentManager);
|
|
441
432
|
/**
|
|
442
|
-
* The callback
|
|
433
|
+
* The callback for grouped tool calls permission decisions.
|
|
443
434
|
*/
|
|
444
|
-
function
|
|
445
|
-
const model = tracker.find(chat => chat.model.name ===
|
|
435
|
+
function toolCallPermissionDecision(sessionId, toolCallId, optionId) {
|
|
436
|
+
const model = tracker.find(chat => chat.model.name === sessionId)
|
|
437
|
+
?.model;
|
|
446
438
|
if (!model) {
|
|
447
439
|
return;
|
|
448
440
|
}
|
|
441
|
+
const isApproved = optionId === 'approve';
|
|
449
442
|
isApproved
|
|
450
|
-
? model.agentManager.approveToolCall(
|
|
451
|
-
: model.agentManager.rejectToolCall(
|
|
443
|
+
? model.agentManager.approveToolCall(toolCallId)
|
|
444
|
+
: model.agentManager.rejectToolCall(toolCallId);
|
|
452
445
|
}
|
|
453
446
|
if (chatComponentsFactory) {
|
|
454
|
-
chatComponentsFactory.
|
|
447
|
+
chatComponentsFactory.groupedToolCallCallbacks = {
|
|
448
|
+
...chatComponentsFactory.groupedToolCallCallbacks,
|
|
449
|
+
toolCallPermissionDecision
|
|
450
|
+
};
|
|
451
|
+
chatComponentsFactory.queueMessageCallbacks = {
|
|
452
|
+
...chatComponentsFactory.queueMessageCallbacks,
|
|
453
|
+
removeQueuedMessage: (targetId, messageId) => {
|
|
454
|
+
const model = tracker.find(chat => chat.model.name === targetId)?.model;
|
|
455
|
+
if (!model) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
model.removeQueuedMessage(messageId);
|
|
459
|
+
},
|
|
460
|
+
reorderQueuedMessages: (targetId, messageIds) => {
|
|
461
|
+
const model = tracker.find(chat => chat.model.name === targetId)?.model;
|
|
462
|
+
if (!model) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
model.reorderQueuedMessages(messageIds);
|
|
466
|
+
},
|
|
467
|
+
editQueuedMessage: (targetId, messageId, newBody) => {
|
|
468
|
+
const model = tracker.find(chat => chat.model.name === targetId)?.model;
|
|
469
|
+
if (!model) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
model.editQueuedMessage(messageId, newBody);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
455
475
|
}
|
|
456
476
|
return tracker;
|
|
457
477
|
}
|
|
@@ -502,11 +522,12 @@ function registerCommands(app, rmRegistry, chatPanel, attachmentOpenerRegistry,
|
|
|
502
522
|
}
|
|
503
523
|
});
|
|
504
524
|
const openInMain = (model) => {
|
|
525
|
+
const inputToolbarRegistry = inputToolbarFactory.create();
|
|
505
526
|
const content = new ChatWidget({
|
|
506
527
|
model,
|
|
507
528
|
rmRegistry,
|
|
508
529
|
themeManager: themeManager ?? null,
|
|
509
|
-
inputToolbarRegistry
|
|
530
|
+
inputToolbarRegistry,
|
|
510
531
|
attachmentOpenerRegistry,
|
|
511
532
|
chatCommandRegistry
|
|
512
533
|
});
|
|
@@ -771,54 +792,25 @@ function registerCommands(app, rmRegistry, chatPanel, attachmentOpenerRegistry,
|
|
|
771
792
|
console.error('Error while moving the chat to main area: there is no reference model');
|
|
772
793
|
return false;
|
|
773
794
|
}
|
|
774
|
-
// Listen for the widget updated in tracker, to ensure the previous model name
|
|
775
|
-
// has been updated. This is required to remove the widget from the restorer
|
|
776
|
-
// when the previous widget is disposed.
|
|
777
|
-
const trackerUpdated = new PromiseDelegate();
|
|
778
|
-
const widgetUpdated = (_, widget) => {
|
|
779
|
-
if (widget.model === previousModel) {
|
|
780
|
-
trackerUpdated.resolve(true);
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
tracker.widgetUpdated.connect(widgetUpdated);
|
|
784
|
-
// Rename temporary the previous model to be able to reuse this name for the new
|
|
785
|
-
// model. The previous is intended to be disposed anyway.
|
|
786
|
-
previousModel.name = UUID.uuid4();
|
|
787
|
-
// Create a new model by duplicating the previous model attributes.
|
|
788
|
-
const model = modelRegistry.createModel({
|
|
789
|
-
name: args.name,
|
|
790
|
-
activeProvider: previousModel.agentManager.activeProvider,
|
|
791
|
-
tokenUsage: previousModel.agentManager.tokenUsage,
|
|
792
|
-
messages: previousModel.messages,
|
|
793
|
-
autosave: previousModel.autosave,
|
|
794
|
-
title: previousModel.title
|
|
795
|
-
});
|
|
796
|
-
// Wait (with timeout) for the tracker to have updated the previous widget.
|
|
797
|
-
const status = await Promise.any([
|
|
798
|
-
trackerUpdated.promise,
|
|
799
|
-
new Promise(r => setTimeout(() => {
|
|
800
|
-
r(false);
|
|
801
|
-
}, 2000))
|
|
802
|
-
]);
|
|
803
|
-
tracker.widgetUpdated.disconnect(widgetUpdated);
|
|
804
|
-
if (!status) {
|
|
805
|
-
return false;
|
|
806
|
-
}
|
|
807
795
|
if (area === 'main') {
|
|
808
|
-
|
|
796
|
+
// Temporarily bypass model disposal to transport model to main view
|
|
797
|
+
// to keep the conversation when switching views
|
|
798
|
+
// TODO: Remove this code when jupyter-chat PR #423 is merged and released
|
|
799
|
+
const originalDispose = previousModel.dispose.bind(previousModel);
|
|
800
|
+
previousModel.dispose = () => { };
|
|
809
801
|
if (previousWidget instanceof ChatWidget) {
|
|
810
|
-
// Clean up the side-panel model entry before disposing the previous
|
|
811
|
-
// widget/model state.
|
|
812
802
|
if (!disposeSideChatModel(previousModel)) {
|
|
813
803
|
previousWidget.dispose();
|
|
814
|
-
previousModel.dispose();
|
|
815
804
|
}
|
|
816
805
|
}
|
|
806
|
+
// Restore model disposal and transport to main view
|
|
807
|
+
previousModel.dispose = originalDispose;
|
|
808
|
+
openInMain(previousModel);
|
|
817
809
|
}
|
|
818
810
|
else {
|
|
811
|
+
// MainAreaChat disposal does not dispose the model internally, so this is safe.
|
|
819
812
|
previousWidget?.dispose();
|
|
820
|
-
|
|
821
|
-
chatPanel.open({ model });
|
|
813
|
+
chatPanel.open({ model: previousModel });
|
|
822
814
|
}
|
|
823
815
|
return true;
|
|
824
816
|
},
|
|
@@ -1313,4 +1305,3 @@ export default [
|
|
|
1313
1305
|
];
|
|
1314
1306
|
// Export extension points for other extensions to use
|
|
1315
1307
|
export * from './tokens';
|
|
1316
|
-
export * from './icons';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { IAIConfig, IMCPServerConfig, IProviderConfig } from '@jupyternaut/agent';
|
|
1
2
|
import { VDomModel } from '@jupyterlab/ui-components';
|
|
2
3
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
3
|
-
import {
|
|
4
|
+
import type { IAISettingsModel } from '../tokens';
|
|
4
5
|
export declare class AISettingsModel extends VDomModel implements IAISettingsModel {
|
|
5
6
|
private _config;
|
|
6
7
|
private _settingRegistry;
|
|
@@ -38,3 +39,4 @@ export declare namespace AISettingsModel {
|
|
|
38
39
|
settingRegistry: ISettingRegistry;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
//# sourceMappingURL=settings-model.d.ts.map
|
|
@@ -19,6 +19,7 @@ export class AISettingsModel extends VDomModel {
|
|
|
19
19
|
diffDisplayMode: 'split',
|
|
20
20
|
skillsPaths: ['.agents/skills', '_agents/skills'],
|
|
21
21
|
chatBackupDirectory: '',
|
|
22
|
+
autoTitle: false,
|
|
22
23
|
commandsRequiringApproval: [
|
|
23
24
|
'notebook:restart-run-all',
|
|
24
25
|
'notebook:run-cell',
|