@jupyterlite/ai 0.14.0 → 0.16.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/agent.d.ts +33 -115
- package/lib/agent.js +192 -106
- package/lib/chat-model-handler.d.ts +9 -11
- package/lib/chat-model-handler.js +9 -4
- package/lib/chat-model.d.ts +84 -13
- package/lib/chat-model.js +214 -136
- package/lib/completion/completion-provider.d.ts +2 -3
- package/lib/components/completion-status.d.ts +2 -2
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/model-select.d.ts +3 -3
- package/lib/components/save-button.d.ts +31 -0
- package/lib/components/save-button.js +41 -0
- package/lib/components/tool-select.d.ts +3 -4
- package/lib/components/{token-usage-display.d.ts → usage-display.d.ts} +13 -14
- package/lib/components/usage-display.js +109 -0
- package/lib/diff-manager.d.ts +2 -3
- package/lib/index.d.ts +2 -4
- package/lib/index.js +186 -28
- package/lib/models/settings-model.d.ts +11 -53
- package/lib/models/settings-model.js +38 -22
- package/lib/providers/built-in-providers.js +22 -36
- package/lib/providers/generated-context-windows.d.ts +8 -0
- package/lib/providers/generated-context-windows.js +96 -0
- package/lib/providers/model-info.d.ts +3 -0
- package/lib/providers/model-info.js +58 -0
- package/lib/tokens.d.ts +361 -36
- package/lib/tokens.js +18 -13
- package/lib/tools/commands.d.ts +2 -3
- package/lib/widgets/ai-settings.d.ts +3 -5
- package/lib/widgets/ai-settings.js +12 -0
- package/lib/widgets/main-area-chat.d.ts +2 -3
- package/lib/widgets/main-area-chat.js +12 -12
- package/lib/widgets/provider-config-dialog.d.ts +1 -2
- package/lib/widgets/provider-config-dialog.js +34 -34
- package/package.json +17 -10
- package/schema/settings-model.json +18 -1
- package/src/agent.ts +275 -248
- package/src/chat-model-handler.ts +25 -21
- package/src/chat-model.ts +307 -196
- package/src/completion/completion-provider.ts +7 -4
- package/src/components/completion-status.tsx +3 -3
- package/src/components/index.ts +1 -1
- package/src/components/model-select.tsx +4 -3
- package/src/components/save-button.tsx +84 -0
- package/src/components/tool-select.tsx +10 -4
- package/src/components/usage-display.tsx +208 -0
- package/src/diff-manager.ts +4 -4
- package/src/index.ts +250 -58
- package/src/models/settings-model.ts +46 -88
- package/src/providers/built-in-providers.ts +22 -36
- package/src/providers/generated-context-windows.ts +102 -0
- package/src/providers/model-info.ts +88 -0
- package/src/tokens.ts +438 -58
- package/src/tools/commands.ts +2 -3
- package/src/widgets/ai-settings.tsx +69 -15
- package/src/widgets/main-area-chat.ts +18 -15
- package/src/widgets/provider-config-dialog.tsx +96 -61
- package/style/base.css +17 -195
- package/lib/approval-buttons.d.ts +0 -49
- package/lib/approval-buttons.js +0 -79
- package/lib/components/token-usage-display.js +0 -72
- package/src/approval-buttons.ts +0 -115
- package/src/components/token-usage-display.tsx +0 -138
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandToolbarButton, MainAreaWidget } from '@jupyterlab/apputils';
|
|
2
2
|
import { launchIcon } from '@jupyterlab/ui-components';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { SaveComponentWidget } from '../components/save-button';
|
|
4
|
+
import { UsageWidget } from '../components/usage-display';
|
|
5
5
|
import { RenderedMessageOutputAreaCompat } from '../rendered-message-outputarea';
|
|
6
6
|
import { CommandIds } from '../tokens';
|
|
7
7
|
/**
|
|
@@ -12,7 +12,7 @@ export class MainAreaChat extends MainAreaWidget {
|
|
|
12
12
|
super(options);
|
|
13
13
|
this.title.label = this.content.model.name;
|
|
14
14
|
const { trans } = options;
|
|
15
|
-
//
|
|
15
|
+
// Move to side button.
|
|
16
16
|
this.toolbar.addItem('moveToSide', new CommandToolbarButton({
|
|
17
17
|
commands: options.commands,
|
|
18
18
|
id: CommandIds.moveChat,
|
|
@@ -22,19 +22,21 @@ export class MainAreaChat extends MainAreaWidget {
|
|
|
22
22
|
},
|
|
23
23
|
icon: launchIcon
|
|
24
24
|
}));
|
|
25
|
+
if (this.model.saveAvailable) {
|
|
26
|
+
// Save chat component
|
|
27
|
+
this.toolbar.addItem('saveChat', new SaveComponentWidget({
|
|
28
|
+
model: this.model,
|
|
29
|
+
translator: trans
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
25
32
|
// Add the token usage button.
|
|
26
|
-
const
|
|
33
|
+
const usageWidget = new UsageWidget({
|
|
27
34
|
tokenUsageChanged: this.model.tokenUsageChanged,
|
|
28
35
|
settingsModel: options.settingsModel,
|
|
29
36
|
initialTokenUsage: this.model.agentManager.tokenUsage,
|
|
30
37
|
translator: trans
|
|
31
38
|
});
|
|
32
|
-
this.toolbar.addItem('
|
|
33
|
-
// Add the approval button, tied to the chat widget.
|
|
34
|
-
this._approvalButtons = new ApprovalButtons({
|
|
35
|
-
chatPanel: this.content,
|
|
36
|
-
agentManager: this.model.agentManager
|
|
37
|
-
});
|
|
39
|
+
this.toolbar.addItem('usage', usageWidget);
|
|
38
40
|
// Temporary compat: keep output-area CSS context for MIME renderers
|
|
39
41
|
// until jupyter-chat provides it natively.
|
|
40
42
|
this._outputAreaCompat = new RenderedMessageOutputAreaCompat({
|
|
@@ -45,7 +47,6 @@ export class MainAreaChat extends MainAreaWidget {
|
|
|
45
47
|
dispose() {
|
|
46
48
|
super.dispose();
|
|
47
49
|
// Dispose of the approval buttons widget when the chat is disposed.
|
|
48
|
-
this._approvalButtons.dispose();
|
|
49
50
|
this._outputAreaCompat.dispose();
|
|
50
51
|
this.model.writersChanged.disconnect(this._writersChanged);
|
|
51
52
|
}
|
|
@@ -73,6 +74,5 @@ export class MainAreaChat extends MainAreaWidget {
|
|
|
73
74
|
this.content.inputToolbarRegistry?.show('send');
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
|
-
_approvalButtons;
|
|
77
77
|
_outputAreaCompat;
|
|
78
78
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { IProviderConfig } from '../
|
|
4
|
-
import type { IProviderRegistry } from '../tokens';
|
|
3
|
+
import type { IProviderConfig, IProviderRegistry } from '../tokens';
|
|
5
4
|
interface IProviderConfigDialogProps {
|
|
6
5
|
open: boolean;
|
|
7
6
|
onClose: () => void;
|
|
@@ -4,6 +4,7 @@ import Visibility from '@mui/icons-material/Visibility';
|
|
|
4
4
|
import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
5
5
|
import { Accordion, AccordionDetails, AccordionSummary, Autocomplete, Box, Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormControlLabel, IconButton, InputAdornment, InputLabel, List, ListItem, ListItemText, MenuItem, Select, Slider, Switch, TextField, Typography } from '@mui/material';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import { getProviderModelInfo } from '../providers/model-info';
|
|
7
8
|
/**
|
|
8
9
|
* Default parameter values for provider configuration
|
|
9
10
|
*/
|
|
@@ -80,6 +81,7 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
80
81
|
const [expandedAdvanced, setExpandedAdvanced] = React.useState(false);
|
|
81
82
|
const selectedProviderInfo = React.useMemo(() => providerRegistry.getProviderInfo(provider), [providerRegistry, provider]);
|
|
82
83
|
const providerToolCapabilities = selectedProviderInfo?.providerToolCapabilities;
|
|
84
|
+
const selectedModelInfo = React.useMemo(() => getProviderModelInfo(selectedProviderInfo, model), [selectedProviderInfo, model]);
|
|
83
85
|
const webSearchImplementation = providerToolCapabilities?.webSearch?.implementation;
|
|
84
86
|
const supportsWebSearch = !!providerToolCapabilities?.webSearch;
|
|
85
87
|
const supportsWebFetch = !!providerToolCapabilities?.webFetch;
|
|
@@ -95,7 +97,6 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
95
97
|
label: info.name,
|
|
96
98
|
models: info.defaultModels,
|
|
97
99
|
apiKeyRequirement: info.apiKeyRequirement,
|
|
98
|
-
allowCustomModel: id === 'generic', // Generic allows custom models
|
|
99
100
|
supportsBaseURL: info.supportsBaseURL,
|
|
100
101
|
description: info.description,
|
|
101
102
|
baseUrls: info.baseUrls
|
|
@@ -106,9 +107,11 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
106
107
|
React.useEffect(() => {
|
|
107
108
|
if (open) {
|
|
108
109
|
// Reset form when dialog opens
|
|
110
|
+
const initialProvider = initialConfig?.provider || 'anthropic';
|
|
111
|
+
const initialProviderInfo = providerRegistry.getProviderInfo(initialProvider);
|
|
109
112
|
setName(initialConfig?.name || '');
|
|
110
|
-
setProvider(
|
|
111
|
-
setModel(initialConfig?.model || '');
|
|
113
|
+
setProvider(initialProvider);
|
|
114
|
+
setModel(initialConfig?.model || initialProviderInfo?.defaultModels[0] || '');
|
|
112
115
|
setApiKey(initialConfig?.apiKey || '');
|
|
113
116
|
setBaseURL(initialConfig?.baseURL || '');
|
|
114
117
|
setParameters(initialConfig?.parameters || {});
|
|
@@ -122,18 +125,17 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
122
125
|
setDomainInputs(createEmptyDomainInputs());
|
|
123
126
|
setExpandedAdvanced(false);
|
|
124
127
|
}
|
|
125
|
-
}, [open, initialConfig]);
|
|
126
|
-
React.useEffect(() => {
|
|
127
|
-
// Auto-select first model when provider changes
|
|
128
|
-
if (selectedProvider && selectedProvider.models.length > 0 && !model) {
|
|
129
|
-
setModel(selectedProvider.models[0]);
|
|
130
|
-
}
|
|
131
|
-
}, [provider, selectedProvider, model]);
|
|
128
|
+
}, [open, initialConfig, providerRegistry]);
|
|
132
129
|
const handleRef = React.useCallback((node) => {
|
|
133
130
|
if (open && node) {
|
|
134
131
|
handleSecretField(node, provider, 'apiKey');
|
|
135
132
|
}
|
|
136
133
|
}, [provider, handleSecretField, open]);
|
|
134
|
+
const handleProviderChange = React.useCallback((newProvider) => {
|
|
135
|
+
const newProviderInfo = providerRegistry.getProviderInfo(newProvider);
|
|
136
|
+
setProvider(newProvider);
|
|
137
|
+
setModel(newProviderInfo?.defaultModels[0] || '');
|
|
138
|
+
}, [providerRegistry]);
|
|
137
139
|
const updateCustomSetting = React.useCallback((section, key, value) => {
|
|
138
140
|
setCustomSettings(prev => {
|
|
139
141
|
const next = { ...prev };
|
|
@@ -247,30 +249,17 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
247
249
|
React.createElement(TextField, { fullWidth: true, label: trans.__('Provider Name'), value: name, onChange: e => setName(e.target.value), placeholder: trans.__('e.g., My Anthropic Config, Work Provider'), helperText: trans.__('A friendly name to identify this provider configuration'), required: true }),
|
|
248
250
|
React.createElement(FormControl, { fullWidth: true, required: true },
|
|
249
251
|
React.createElement(InputLabel, null, trans.__('Provider Type')),
|
|
250
|
-
React.createElement(Select, { value: provider, label: trans.__('Provider Type'), onChange: e =>
|
|
252
|
+
React.createElement(Select, { value: provider, label: trans.__('Provider Type'), onChange: e => handleProviderChange(e.target.value) }, providerOptions.map(option => (React.createElement(MenuItem, { key: option.value, value: option.value },
|
|
251
253
|
React.createElement(Box, null,
|
|
252
254
|
React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 } },
|
|
253
255
|
option.label,
|
|
254
256
|
option.apiKeyRequirement === 'required' && (React.createElement(Chip, { size: "small", label: trans.__('API Key'), color: "default", variant: "outlined" }))),
|
|
255
257
|
option.description && (React.createElement(Typography, { variant: "caption", color: "text.secondary" }, option.description)))))))),
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
React.createElement(Typography, { variant: "caption", color: "text.secondary" }, modelOption.includes('sonnet')
|
|
262
|
-
? trans.__('Balanced performance')
|
|
263
|
-
: modelOption.includes('opus')
|
|
264
|
-
? trans.__('Advanced reasoning')
|
|
265
|
-
: modelOption.includes('haiku')
|
|
266
|
-
? trans.__('Fast and lightweight')
|
|
267
|
-
: modelOption.includes('large')
|
|
268
|
-
? trans.__('Most capable model')
|
|
269
|
-
: modelOption.includes('small')
|
|
270
|
-
? trans.__('Fast and efficient')
|
|
271
|
-
: modelOption.includes('codestral')
|
|
272
|
-
? trans.__('Code-specialized')
|
|
273
|
-
: trans.__('General purpose'))))))))),
|
|
258
|
+
React.createElement(Autocomplete, { freeSolo: true, fullWidth: true, options: selectedProvider?.models ?? [], value: model, onChange: (_, value) => {
|
|
259
|
+
setModel(typeof value === 'string' ? value : '');
|
|
260
|
+
}, inputValue: model, onInputChange: (_, value) => {
|
|
261
|
+
setModel(value);
|
|
262
|
+
}, renderInput: params => (React.createElement(TextField, { ...params, fullWidth: true, label: trans.__('Model'), placeholder: trans.__('Select or type a model ID'), required: true, helperText: trans.__('Choose from the list or enter a custom model ID') })), clearOnBlur: false }),
|
|
274
263
|
selectedProvider &&
|
|
275
264
|
selectedProvider?.apiKeyRequirement !== 'none' && (React.createElement(TextField, { fullWidth: true, inputRef: handleRef, label: selectedProvider?.apiKeyRequirement === 'required'
|
|
276
265
|
? trans.__('API Key')
|
|
@@ -313,13 +302,24 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
313
302
|
maxOutputTokens: e.target.value
|
|
314
303
|
? Number(e.target.value)
|
|
315
304
|
: undefined
|
|
316
|
-
}), placeholder: trans.__('Leave empty for provider default'), helperText: trans.__('Maximum length of AI responses'),
|
|
305
|
+
}), placeholder: trans.__('Leave empty for provider default'), helperText: trans.__('Maximum length of AI responses'), slotProps: { htmlInput: { min: 1 } } }),
|
|
317
306
|
React.createElement(TextField, { fullWidth: true, label: trans.__('Max Turns (Optional)'), type: "number", value: parameters.maxTurns ?? '', onChange: e => setParameters({
|
|
318
307
|
...parameters,
|
|
319
308
|
maxTurns: e.target.value
|
|
320
309
|
? Number(e.target.value)
|
|
321
310
|
: undefined
|
|
322
|
-
}), placeholder: trans.__('Default: %1', DEFAULT_MAX_TURNS), helperText: trans.__('Maximum number of tool execution turns'),
|
|
311
|
+
}), placeholder: trans.__('Default: %1', DEFAULT_MAX_TURNS), helperText: trans.__('Maximum number of tool execution turns'), slotProps: { htmlInput: { min: 1, max: 100 } } }),
|
|
312
|
+
React.createElement(TextField, { fullWidth: true, label: trans.__('Context Window (Optional)'), type: "number", value: parameters.contextWindow ?? '', onChange: e => setParameters({
|
|
313
|
+
...parameters,
|
|
314
|
+
contextWindow: e.target.value
|
|
315
|
+
? Number(e.target.value)
|
|
316
|
+
: undefined
|
|
317
|
+
}), placeholder: selectedModelInfo?.contextWindow !== undefined
|
|
318
|
+
? trans.__('Default: %1', selectedModelInfo.contextWindow.toLocaleString())
|
|
319
|
+
: trans.__('e.g., 128000'), helperText: selectedModelInfo?.contextWindow !== undefined &&
|
|
320
|
+
parameters.contextWindow === undefined
|
|
321
|
+
? trans.__('Using provider metadata default of %1 tokens for this model unless you override it here.', selectedModelInfo.contextWindow.toLocaleString())
|
|
322
|
+
: trans.__('Model context window size in tokens (used for context usage estimation)'), slotProps: { htmlInput: { min: 1 } } }),
|
|
323
323
|
React.createElement(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 2, mb: 1 } }, trans.__('Completion Options')),
|
|
324
324
|
React.createElement(FormControlLabel, { control: React.createElement(Switch, { checked: parameters.supportsFillInMiddle ?? false, onChange: e => setParameters({
|
|
325
325
|
...parameters,
|
|
@@ -357,7 +357,7 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
357
357
|
webSearchImplementation === 'anthropic' && (React.createElement(React.Fragment, null,
|
|
358
358
|
React.createElement(TextField, { fullWidth: true, label: trans.__('Web Search Max Uses'), type: "number", value: webSearchSettings.maxUses ?? '', onChange: e => updateCustomSetting('webSearch', 'maxUses', e.target.value
|
|
359
359
|
? Number(e.target.value)
|
|
360
|
-
: undefined),
|
|
360
|
+
: undefined), slotProps: { htmlInput: { min: 1 } } }),
|
|
361
361
|
renderDomainList('webSearch.blockedDomains', trans.__('Blocked Domains'), trans.__('spam.example.com'), webSearchSettings.blockedDomains))))))),
|
|
362
362
|
supportsWebFetch && (React.createElement(React.Fragment, null,
|
|
363
363
|
React.createElement(FormControlLabel, { control: React.createElement(Switch, { checked: webFetchSettings.enabled === true, onChange: e => updateCustomSetting('webFetch', 'enabled', e.target.checked) }), label: trans.__('Enable Web Fetch') }),
|
|
@@ -371,10 +371,10 @@ export const ProviderConfigDialog = ({ open, onClose, onSave, initialConfig, mod
|
|
|
371
371
|
} },
|
|
372
372
|
React.createElement(TextField, { fullWidth: true, label: trans.__('Web Fetch Max Uses'), type: "number", value: webFetchSettings.maxUses ?? '', onChange: e => updateCustomSetting('webFetch', 'maxUses', e.target.value
|
|
373
373
|
? Number(e.target.value)
|
|
374
|
-
: undefined),
|
|
374
|
+
: undefined), slotProps: { htmlInput: { min: 1 } } }),
|
|
375
375
|
React.createElement(TextField, { fullWidth: true, label: trans.__('Web Fetch Max Content Tokens'), type: "number", value: webFetchSettings.maxContentTokens ?? '', onChange: e => updateCustomSetting('webFetch', 'maxContentTokens', e.target.value
|
|
376
376
|
? Number(e.target.value)
|
|
377
|
-
: undefined),
|
|
377
|
+
: undefined), slotProps: { htmlInput: { min: 1 } } }),
|
|
378
378
|
renderDomainList('webFetch.allowedDomains', trans.__('Allowed Domains'), trans.__('docs.example.com'), webFetchSettings.allowedDomains),
|
|
379
379
|
renderDomainList('webFetch.blockedDomains', trans.__('Blocked Domains'), trans.__('spam.example.com'), webFetchSettings.blockedDomains),
|
|
380
380
|
React.createElement(FormControlLabel, { control: React.createElement(Switch, { checked: webFetchSettings.citationsEnabled === true, onChange: e => updateCustomSetting('webFetch', 'citationsEnabled', e.target.checked) }), label: trans.__('Enable Citations') })))))))))))),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlite/ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "AI code completions and chat for JupyterLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -53,16 +53,17 @@
|
|
|
53
53
|
"watch:src": "tsc -w --sourceMap",
|
|
54
54
|
"watch:labextension": "jupyter labextension watch .",
|
|
55
55
|
"docs": "jupyter book start",
|
|
56
|
-
"docs:build": "sed -e 's/\\[@/[/g' -e 's/@/\\@/g' CHANGELOG.md > docs/_changelog_content.md && jupyter book build --html"
|
|
56
|
+
"docs:build": "sed -e 's/\\[@/[/g' -e 's/@/\\@/g' CHANGELOG.md > docs/_changelog_content.md && jupyter book build --html",
|
|
57
|
+
"sync:model-context-windows": "node scripts/sync-model-context-windows.mjs && prettier --write src/providers/generated-context-windows.ts && eslint --fix src/providers/generated-context-windows.ts"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
60
|
-
"@ai-sdk/google": "^3.0.
|
|
61
|
-
"@ai-sdk/mcp": "^1.0.
|
|
62
|
-
"@ai-sdk/mistral": "^3.0.
|
|
63
|
-
"@ai-sdk/openai": "^3.0.
|
|
64
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
65
|
-
"@jupyter/chat": "^0.
|
|
60
|
+
"@ai-sdk/anthropic": "^3.0.58",
|
|
61
|
+
"@ai-sdk/google": "^3.0.43",
|
|
62
|
+
"@ai-sdk/mcp": "^1.0.25",
|
|
63
|
+
"@ai-sdk/mistral": "^3.0.24",
|
|
64
|
+
"@ai-sdk/openai": "^3.0.41",
|
|
65
|
+
"@ai-sdk/openai-compatible": "^2.0.35",
|
|
66
|
+
"@jupyter/chat": "^0.21.1",
|
|
66
67
|
"@jupyterlab/application": "^4.0.0",
|
|
67
68
|
"@jupyterlab/apputils": "^4.5.6",
|
|
68
69
|
"@jupyterlab/cells": "^4.4.6",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"@jupyterlab/coreutils": "^6.4.6",
|
|
71
72
|
"@jupyterlab/docmanager": "^4.4.6",
|
|
72
73
|
"@jupyterlab/docregistry": "^4.4.6",
|
|
74
|
+
"@jupyterlab/filebrowser": "^4.5.6",
|
|
73
75
|
"@jupyterlab/fileeditor": "^4.4.6",
|
|
74
76
|
"@jupyterlab/notebook": "^4.4.6",
|
|
75
77
|
"@jupyterlab/rendermime": "^4.4.6",
|
|
@@ -86,7 +88,8 @@
|
|
|
86
88
|
"@lumino/widgets": "^2.7.1",
|
|
87
89
|
"@mui/icons-material": "^7",
|
|
88
90
|
"@mui/material": "^7",
|
|
89
|
-
"ai": "^6.0.
|
|
91
|
+
"ai": "^6.0.116",
|
|
92
|
+
"jupyter-chat-components": "^0.2.0",
|
|
90
93
|
"jupyter-secrets-manager": "^0.5.0",
|
|
91
94
|
"yaml": "^2.8.1",
|
|
92
95
|
"zod": "^4.3.6"
|
|
@@ -133,6 +136,10 @@
|
|
|
133
136
|
"@jupyter/chat": {
|
|
134
137
|
"bundled": true,
|
|
135
138
|
"singleton": true
|
|
139
|
+
},
|
|
140
|
+
"jupyter-chat-components": {
|
|
141
|
+
"bundled": false,
|
|
142
|
+
"singleton": true
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
},
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
"maximum": 100,
|
|
55
55
|
"default": 25
|
|
56
56
|
},
|
|
57
|
+
"contextWindow": {
|
|
58
|
+
"type": "number",
|
|
59
|
+
"description": "Model context window size in tokens (used for context usage estimation)",
|
|
60
|
+
"minimum": 1
|
|
61
|
+
},
|
|
57
62
|
"supportsFillInMiddle": {
|
|
58
63
|
"type": "boolean",
|
|
59
64
|
"description": "Whether the model supports fill-in-middle completion"
|
|
@@ -211,6 +216,12 @@
|
|
|
211
216
|
"type": "boolean",
|
|
212
217
|
"default": false
|
|
213
218
|
},
|
|
219
|
+
"showContextUsage": {
|
|
220
|
+
"title": "Show Context Usage",
|
|
221
|
+
"description": "Display estimated context usage percentage in the chat toolbar",
|
|
222
|
+
"type": "boolean",
|
|
223
|
+
"default": false
|
|
224
|
+
},
|
|
214
225
|
"commandsRequiringApproval": {
|
|
215
226
|
"title": "Commands Requiring Approval",
|
|
216
227
|
"description": "List of commands that require user approval before AI can execute them",
|
|
@@ -251,7 +262,7 @@
|
|
|
251
262
|
"title": "System Prompt",
|
|
252
263
|
"description": "Instructions that define how the AI should behave and respond",
|
|
253
264
|
"type": "string",
|
|
254
|
-
"default": "You are Jupyternaut, an AI coding assistant built specifically for the JupyterLab environment.\n\n## Your Core Mission\nYou're designed to be a capable partner for data science, research, and development work in Jupyter notebooks. You can help with everything from quick code snippets to complex multi-notebook projects.\n\n## Your Capabilities\n**📁 File & Project Management:**\n- Create, read, edit, and organize files and notebooks in any language\n- Manage project structure and navigate file systems\n- Help with version control and project organization\n\n**📊 Notebook Operations:**\n- Create new notebooks and manage existing ones\n- Add, edit, delete, and run cells (both code and markdown)\n- Help with notebook structure and organization\n- Retrieve and analyze cell outputs and execution results\n\n**⚡ Kernel Management:**\n- Start new kernels with specified language or kernel name\n- Execute code directly in a kernel using jupyterlab-ai-commands execution commands (not console), without creating cells\n- List running kernels and monitor their status\n- Manage kernel lifecycle (start, monitor, shutdown)\n\n**🧠 Coding & Development:**\n- Write, debug, and optimize code in any language supported by Jupyter kernels (Python, R, Julia, JavaScript, C++, and more)\n- Explain complex algorithms and data structures\n- Help with data analysis, visualization, and machine learning\n- Support for libraries and packages across different languages\n- Code reviews and best practices recommendations\n\n**💡 Adaptive Assistance:**\n- Understand context from the user's current work environment\n- Provide suggestions tailored to the user's specific use case\n- Help with both quick fixes and long-term project planning\n\n## How You Work\nYou interact with the user's JupyterLab environment primarily through the command system:\n- Use 'discover_commands' to find available JupyterLab commands\n- Use 'execute_command' to perform operations\n- For file and notebook operations, use commands from the jupyterlab-ai-commands extension (prefixed with 'jupyterlab-ai-commands:')\n- These commands provide comprehensive file and notebook manipulation: create, read, edit files/notebooks, manage cells, run code, etc.\n- You can make systematic changes across multiple files and perform complex multi-step operations\n- Skills are available via the skills tools: discover_skills (list) and load_skill (load instructions/resources)\n\n## Tool & Skill Use Policy\\n- When tools or skills are available and the task requires actions or environment-specific facts, use them instead of guessing\\n- Never guess command IDs. Always use discover_commands with a relevant query before execute_command, unless you already discovered the command earlier in this conversation\\n- If a preloaded skills snapshot is provided in the system prompt, use it instead of calling discover_skills to list skills\\n- Only call discover_skills if the user explicitly asks for the latest list or you need to verify a skill not in the snapshot\n- When a skill is relevant, call load_skill with the skill name to load instructions; if it returns a non-empty resources array, load each listed resource with load_skill before proceeding\\n- If you're unsure how to perform a request, discover relevant commands (discover_commands with task keywords)\\n- Use a relevant skill even when the user doesn't explicitly mention it\\n- Prefer the single most relevant tool or skill; if multiple could apply, ask a brief clarifying question\n- Ask for missing required inputs before calling a tool or skill\n- Before calling a tool or skill, briefly state why you're calling it\n\n## Code Execution Strategy\nWhen asked to run code or perform computations, choose the most appropriate approach:\n- **For quick computations or one-off code execution**: Use the kernel execution commands from jupyterlab-ai-commands to run code directly (no notebook/console). Discover these commands first with query 'jupyterlab-ai-commands' and use the returned command IDs. This is ideal for calculations, data lookups, or testing code snippets.\n- **For work that should be saved**: Create or use notebooks when the user needs a persistent record of their work, wants to iterate on code, or is building something they'll return to later.\n\nThis means if the user asks you to \"calculate the factorial of 100\" or \"check what library version is installed\", run that directly with the jupyterlab-ai-commands kernel execution command rather than creating a new notebook file.\n\n## Your Approach\n- **Context-aware**: You understand the user is working in a data science/research environment\n- **Practical**: You focus on actionable solutions that work in the user's current setup\n- **Educational**: You explain your reasoning and teach best practices along the way\n- **Collaborative**: You are a pair programming partner, not just a code generator\n\n## Communication Style & Agent Behavior\nIMPORTANT: Follow this message flow pattern for better user experience:\n\n1. FIRST: Explain what you're going to do and your approach\n2. THEN: Execute tools (these will show automatically with step numbers)\n3. FINALLY: Provide a concise summary of what was accomplished\n\nExample flow:\n- \"I'll help you create a notebook with example cells. Let me first create the file structure, then add Python and Markdown cells.\"\n- [Tool executions happen with automatic step display]\n- \"Successfully created your notebook with 3 cells: a title, code example, and visualization cell.\"\n\nGuidelines:\n- Start responses with your plan/approach before tool execution\n- Let the system handle tool execution display (don't duplicate details)\n- End with a brief summary of accomplishments\n- Use natural, conversational tone throughout\n\n- **Conversational**: You maintain a friendly, natural conversation flow throughout the interaction\n- **Progress Updates**: You write brief progress messages between tool uses that appear directly in the conversation\n- **No Filler**: You avoid empty acknowledgments like \"Sounds good!\" or \"Okay, I will...\" - you get straight to work\n- **Purposeful Communication**: You start with what you're doing, use tools, then share what you found and what's next\n- **Active Narration**: You actively write progress updates like \"Looking at the current code structure...\" or \"Found the issue in the notebook...\" between tool calls\n- **Checkpoint Updates**: After several operations, you summarize what you've accomplished and what remains\n- **Natural Flow**: Your explanations and progress reports appear as normal conversation text, not just in tool blocks\n\n## IMPORTANT: Always write progress messages between tools that explain what you're doing and what you found. These should be conversational updates that help the user follow along with your work.\n\n## Technical Communication\n- Code is formatted in proper markdown blocks with syntax highlighting\n- Mathematical notation uses LaTeX formatting: \\\\(equations\\\\) and \\\\[display math\\\\]\n- You provide context for your actions and explain your reasoning as you work\n- When creating or modifying multiple files, you give brief summaries of changes\n- You keep users informed of progress while staying focused on the task\n\n## Multi-Step Task Handling\nWhen users request complex tasks, you use the command system to accomplish them:\n- For file and notebook operations, use discover_commands with query 'jupyterlab-ai-commands' to find the curated set of AI commands (~17 commands)\n- For other JupyterLab operations (terminal, launcher, UI), use specific keywords like 'terminal', 'launcher', etc.\n- IMPORTANT: Always use 'jupyterlab-ai-commands' as the query for file/notebook tasks - this returns a focused set instead of 100+ generic commands\n- For example, to create a notebook with cells:\n 1. discover_commands with query 'jupyterlab-ai-commands' to find available file/notebook commands\n 2. execute_command with 'jupyterlab-ai-commands:create-notebook' and required arguments\n 3. execute_command with 'jupyterlab-ai-commands:add-cell' multiple times to add cells\n 4. execute_command with 'jupyterlab-ai-commands:set-cell-content' to add content to cells\n 5. execute_command with 'jupyterlab-ai-commands:run-cell' when appropriate\n\n## Kernel Preference for Notebooks and Consoles\nWhen creating notebooks or consoles for a specific programming language, use the 'kernelPreference' argument:\nOnly create consoles when the user explicitly asks for one; otherwise prefer the jupyterlab-ai-commands kernel execution commands for running code.\n- To specify by language: { \"kernelPreference\": { \"language\": \"python\" } } or { \"kernelPreference\": { \"language\": \"julia\" } }\n- To specify by kernel name: { \"kernelPreference\": { \"name\": \"python3\" } } or { \"kernelPreference\": { \"name\": \"julia-1.10\" } }\n- Example: execute_command with commandId=\"notebook:create-new\" and args={ \"kernelPreference\": { \"language\": \"python\" } }\n- Example: execute_command with commandId=\"console:create\" and args={ \"kernelPreference\": { \"name\": \"python3\" } }\n- Common kernel names: \"python3\" (Python), \"julia-1.10\" (Julia), \"ir\" (R), \"xpython\" (xeus-python)\n- If unsure of exact kernel name, prefer using \"language\" which will match any kernel supporting that language\n\nAlways think through multi-step tasks and use commands to fully complete the user's request rather than stopping after just one action.\n\nYou are ready to help users build something great!"
|
|
265
|
+
"default": "You are Jupyternaut, an AI coding assistant built specifically for the JupyterLab environment.\n\n## Your Core Mission\nYou're designed to be a capable partner for data science, research, and development work in Jupyter notebooks. You can help with everything from quick code snippets to complex multi-notebook projects.\n\n## Your Capabilities\n**📁 File & Project Management:**\n- Create, read, edit, and organize files and notebooks in any language\n- Manage project structure and navigate file systems\n- Help with version control and project organization\n\n**📊 Notebook Operations:**\n- Create new notebooks and manage existing ones\n- Add, edit, delete, and run cells (both code and markdown)\n- Help with notebook structure and organization\n- Retrieve and analyze cell outputs and execution results\n\n**⚡ Kernel Management:**\n- Start new kernels with specified language or kernel name\n- Execute code directly in a kernel using jupyterlab-ai-commands execution commands (not console), without creating cells\n- List running kernels and monitor their status\n- Manage kernel lifecycle (start, monitor, shutdown)\n\n**🧠 Coding & Development:**\n- Write, debug, and optimize code in any language supported by Jupyter kernels (Python, R, Julia, JavaScript, C++, and more)\n- Explain complex algorithms and data structures\n- Help with data analysis, visualization, and machine learning\n- Support for libraries and packages across different languages\n- Code reviews and best practices recommendations\n\n**💡 Adaptive Assistance:**\n- Understand context from the user's current work environment\n- Provide suggestions tailored to the user's specific use case\n- Help with both quick fixes and long-term project planning\n\n## How You Work\nYou interact with the user's JupyterLab environment primarily through the command system:\n- Use 'discover_commands' to find available JupyterLab commands\n- Use 'execute_command' to perform operations\n- For file and notebook operations, use commands from the jupyterlab-ai-commands extension (prefixed with 'jupyterlab-ai-commands:')\n- These commands provide comprehensive file and notebook manipulation: create, read, edit files/notebooks, manage cells, run code, etc.\n- You can make systematic changes across multiple files and perform complex multi-step operations\n- Skills are available via the skills tools: discover_skills (list) and load_skill (load instructions/resources)\n\n## Tool & Skill Use Policy\\n- When tools or skills are available and the task requires actions or environment-specific facts, use them instead of guessing\\n- Never guess command IDs. Always use discover_commands with a relevant query before execute_command, unless you already discovered the command earlier in this conversation\\n- If a preloaded skills snapshot is provided in the system prompt, use it instead of calling discover_skills to list skills\\n- Only call discover_skills if the user explicitly asks for the latest list or you need to verify a skill not in the snapshot\n- When a skill is relevant, call load_skill with the skill name to load instructions; if it returns a non-empty resources array, load each listed resource with load_skill before proceeding\\n- If you're unsure how to perform a request, discover relevant commands (discover_commands with task keywords)\\n- Use a relevant skill even when the user doesn't explicitly mention it\\n- Prefer the single most relevant tool or skill; if multiple could apply, ask a brief clarifying question\n- Ask for missing required inputs before calling a tool or skill\n- Before calling a tool or skill, briefly state why you're calling it\n\n## Code Execution Strategy\nWhen asked to run code or perform computations, choose the most appropriate approach:\n- **For quick computations or one-off code execution**: Use the kernel execution commands from jupyterlab-ai-commands to run code directly (no notebook/console). Discover these commands first with query 'jupyterlab-ai-commands' and use the returned command IDs. This is ideal for calculations, data lookups, or testing code snippets.\n- **For work that should be saved**: Create or use notebooks when the user needs a persistent record of their work, wants to iterate on code, or is building something they'll return to later.\n\nThis means if the user asks you to \"calculate the factorial of 100\" or \"check what library version is installed\", run that directly with the jupyterlab-ai-commands kernel execution command rather than creating a new notebook file.\n\n## Notebook State and Cell Identity\nWhen working with an existing notebook, use the notebook's current structure and kernel state as the source of truth.\n- Before changing notebook content or structure, inspect the notebook and any target cells with the relevant notebook commands you have discovered.\n- If the user may have edited the notebook, or if a previous command could have changed it, refresh your view before continuing rather than relying on earlier results.\n- Treat variables from previously executed cells as part of the active kernel state. When the user asks you to work with existing data or variables, use them by name instead of recreating them unless the user asks you to redefine them or the kernel state is unavailable.\n- Be explicit about the kind of cell reference you are using. A visible execution count (for example In [6]), a notebook position, and an internal cell ID or UUID are different identifiers and may not match.\n- When the user identifies a cell by execution count, relative position, or content, verify the target cell from the current notebook contents before editing it or inserting cells relative to it.\n- For relative insertions, anchor the change to the confirmed target cell rather than to empty placeholder or trailing cells unless the user explicitly refers to those cells.\n\n## Your Approach\n- **Context-aware**: You understand the user is working in a data science/research environment\n- **Practical**: You focus on actionable solutions that work in the user's current setup\n- **Educational**: You explain your reasoning and teach best practices along the way\n- **Collaborative**: You are a pair programming partner, not just a code generator\n\n## Communication Style & Agent Behavior\nIMPORTANT: Follow this message flow pattern for better user experience:\n\n1. FIRST: Explain what you're going to do and your approach\n2. THEN: Execute tools (these will show automatically with step numbers)\n3. FINALLY: Provide a concise summary of what was accomplished\n\nExample flow:\n- \"I'll help you create a notebook with example cells. Let me first create the file structure, then add Python and Markdown cells.\"\n- [Tool executions happen with automatic step display]\n- \"Successfully created your notebook with 3 cells: a title, code example, and visualization cell.\"\n\nGuidelines:\n- Start responses with your plan/approach before tool execution\n- Let the system handle tool execution display (don't duplicate details)\n- End with a brief summary of accomplishments\n- Use natural, conversational tone throughout\n\n- **Conversational**: You maintain a friendly, natural conversation flow throughout the interaction\n- **Progress Updates**: You write brief progress messages between tool uses that appear directly in the conversation\n- **No Filler**: You avoid empty acknowledgments like \"Sounds good!\" or \"Okay, I will...\" - you get straight to work\n- **Purposeful Communication**: You start with what you're doing, use tools, then share what you found and what's next\n- **Active Narration**: You actively write progress updates like \"Looking at the current code structure...\" or \"Found the issue in the notebook...\" between tool calls\n- **Checkpoint Updates**: After several operations, you summarize what you've accomplished and what remains\n- **Natural Flow**: Your explanations and progress reports appear as normal conversation text, not just in tool blocks\n\n## IMPORTANT: Always write progress messages between tools that explain what you're doing and what you found. These should be conversational updates that help the user follow along with your work.\n\n## Technical Communication\n- Code is formatted in proper markdown blocks with syntax highlighting\n- Mathematical notation uses LaTeX formatting: \\\\(equations\\\\) and \\\\[display math\\\\]\n- You provide context for your actions and explain your reasoning as you work\n- When creating or modifying multiple files, you give brief summaries of changes\n- You keep users informed of progress while staying focused on the task\n\n## Multi-Step Task Handling\nWhen users request complex tasks, you use the command system to accomplish them:\n- For file and notebook operations, use discover_commands with query 'jupyterlab-ai-commands' to find the curated set of AI commands (~22 commands)\n- For other JupyterLab operations (terminal, launcher, UI), use specific keywords like 'terminal', 'launcher', etc.\n- IMPORTANT: Always use 'jupyterlab-ai-commands' as the query for file/notebook tasks - this returns a focused set instead of 100+ generic commands\n- For example, to create a notebook with cells:\n 1. discover_commands with query 'jupyterlab-ai-commands' to find available file/notebook commands\n 2. execute_command with 'jupyterlab-ai-commands:create-notebook' and required arguments\n 3. execute_command with 'jupyterlab-ai-commands:add-cell' multiple times to add cells\n 4. execute_command with 'jupyterlab-ai-commands:set-cell-content' to add content to cells\n 5. execute_command with 'jupyterlab-ai-commands:run-cell' when appropriate\n\n## Kernel Preference for Notebooks and Consoles\nWhen creating notebooks or consoles for a specific programming language, use the 'kernelPreference' argument:\nOnly create consoles when the user explicitly asks for one; otherwise prefer the jupyterlab-ai-commands kernel execution commands for running code.\n- To specify by language: { \"kernelPreference\": { \"language\": \"python\" } } or { \"kernelPreference\": { \"language\": \"julia\" } }\n- To specify by kernel name: { \"kernelPreference\": { \"name\": \"python3\" } } or { \"kernelPreference\": { \"name\": \"julia-1.10\" } }\n- Example: execute_command with commandId=\"notebook:create-new\" and args={ \"kernelPreference\": { \"language\": \"python\" } }\n- Example: execute_command with commandId=\"console:create\" and args={ \"kernelPreference\": { \"name\": \"python3\" } }\n- Common kernel names: \"python3\" (Python), \"julia-1.10\" (Julia), \"ir\" (R), \"xpython\" (xeus-python)\n- If unsure of exact kernel name, prefer using \"language\" which will match any kernel supporting that language\n\nAlways think through multi-step tasks and use commands to fully complete the user's request rather than stopping after just one action.\n\nYou are ready to help users build something great!"
|
|
255
266
|
},
|
|
256
267
|
"completionSystemPrompt": {
|
|
257
268
|
"title": "Completion System Prompt",
|
|
@@ -284,6 +295,12 @@
|
|
|
284
295
|
"type": "array",
|
|
285
296
|
"items": { "type": "string" },
|
|
286
297
|
"default": [".agents/skills", "_agents/skills"]
|
|
298
|
+
},
|
|
299
|
+
"chatBackupDirectory": {
|
|
300
|
+
"title": "Chat Backup Directory",
|
|
301
|
+
"description": "Directory where chat history backups are saved, relative to the server root. Default is the server root.",
|
|
302
|
+
"type": "string",
|
|
303
|
+
"default": ""
|
|
287
304
|
}
|
|
288
305
|
},
|
|
289
306
|
"additionalProperties": false
|