@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,6 +1,7 @@
|
|
|
1
|
+
import { IProviderRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { CompletionHandler, IInlineCompletionContext, IInlineCompletionList, IInlineCompletionProvider } from '@jupyterlab/completer';
|
|
2
3
|
import { ISecretsManager } from 'jupyter-secrets-manager';
|
|
3
|
-
import {
|
|
4
|
+
import type { IAISettingsModel } from '../tokens';
|
|
4
5
|
/**
|
|
5
6
|
* Configuration interface for provider-specific completion behavior
|
|
6
7
|
*/
|
|
@@ -82,3 +83,4 @@ export declare namespace AICompletionProvider {
|
|
|
82
83
|
token: symbol | null;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
86
|
+
//# sourceMappingURL=completion-provider.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createCompletionModel, SECRETS_NAMESPACE } from '@jupyternaut/agent';
|
|
1
2
|
import { NotebookPanel } from '@jupyterlab/notebook';
|
|
2
3
|
import { generateText } from 'ai';
|
|
3
|
-
import { createCompletionModel } from '../providers/models';
|
|
4
|
-
import { SECRETS_NAMESPACE } from '../tokens';
|
|
5
4
|
/**
|
|
6
5
|
* Default temperature for code completion (lower than chat for more deterministic results)
|
|
7
6
|
*/
|
|
@@ -21,3 +21,4 @@ export declare function ClearButton(props: IClearButtonProps): JSX.Element;
|
|
|
21
21
|
* Factory returning the clear button toolbar item.
|
|
22
22
|
*/
|
|
23
23
|
export declare function clearItem(translator: TranslationBundle): InputToolbarRegistry.IToolbarItem;
|
|
24
|
+
//# sourceMappingURL=clear-button.d.ts.map
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { TooltippedButton } from '@jupyter/chat';
|
|
2
3
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
3
|
-
import React from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* The clear button component.
|
|
6
6
|
*/
|
|
7
7
|
export function ClearButton(props) {
|
|
8
8
|
const { translator: trans } = props;
|
|
9
9
|
const tooltip = trans.__('Clear chat');
|
|
10
|
-
return (
|
|
10
|
+
return (_jsx(TooltippedButton, { onClick: props.clearMessages, tooltip: tooltip, buttonProps: {
|
|
11
11
|
title: tooltip,
|
|
12
12
|
variant: 'outlined',
|
|
13
13
|
color: 'secondary'
|
|
14
|
-
} }
|
|
15
|
-
React.createElement(ClearIcon, null)));
|
|
14
|
+
}, children: _jsx(ClearIcon, {}) }));
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
17
|
* Factory returning the clear button toolbar item.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
2
3
|
import { ReactWidget } from '@jupyterlab/ui-components';
|
|
3
|
-
import { jupyternautIcon } from '
|
|
4
|
+
import { jupyternautIcon } from '@jupyternaut/agent';
|
|
4
5
|
const COMPLETION_STATUS_CLASS = 'jp-ai-completion-status';
|
|
5
6
|
const COMPLETION_DISABLED_CLASS = 'jp-ai-completion-disabled';
|
|
6
7
|
/**
|
|
@@ -34,7 +35,7 @@ function CompletionStatus(props) {
|
|
|
34
35
|
props.settingsModel.stateChanged.disconnect(stateChanged);
|
|
35
36
|
};
|
|
36
37
|
}, [props.settingsModel, trans]);
|
|
37
|
-
return (
|
|
38
|
+
return (_jsx(jupyternautIcon.react, { className: disabled ? COMPLETION_DISABLED_CLASS : '', top: '2px', width: '16px', stylesheet: 'statusBar', title: title }));
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* The completion status widget that will be added to the status bar.
|
|
@@ -46,7 +47,7 @@ export class CompletionStatusWidget extends ReactWidget {
|
|
|
46
47
|
this._props = options;
|
|
47
48
|
}
|
|
48
49
|
render() {
|
|
49
|
-
return
|
|
50
|
+
return _jsx(CompletionStatus, { ...this._props });
|
|
50
51
|
}
|
|
51
52
|
_props;
|
|
52
53
|
}
|
|
@@ -22,3 +22,4 @@ export declare function ModelSelect(props: IModelSelectProps): JSX.Element;
|
|
|
22
22
|
* Factory function returning the toolbar item for model selection.
|
|
23
23
|
*/
|
|
24
24
|
export declare function createModelSelectItem(settingsModel: IAISettingsModel, translator: TranslationBundle): InputToolbarRegistry.IToolbarItem;
|
|
25
|
+
//# sourceMappingURL=model-select.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
2
|
import { TooltippedButton } from '@jupyter/chat';
|
|
2
3
|
import CheckIcon from '@mui/icons-material/Check';
|
|
3
4
|
import { Menu, MenuItem, Typography } from '@mui/material';
|
|
4
|
-
import
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
6
|
/**
|
|
6
7
|
* The model select component for choosing AI models.
|
|
7
8
|
*/
|
|
@@ -60,7 +61,7 @@ export function ModelSelect(props) {
|
|
|
60
61
|
}));
|
|
61
62
|
// Show a message if no providers are configured
|
|
62
63
|
if (availableModels.length === 0) {
|
|
63
|
-
return (
|
|
64
|
+
return (_jsx(TooltippedButton, { onClick: () => { }, tooltip: trans.__('No providers configured. Please go to AI Settings to add a provider.'), buttonProps: {
|
|
64
65
|
variant: 'outlined',
|
|
65
66
|
color: 'warning',
|
|
66
67
|
disabled: true,
|
|
@@ -70,72 +71,66 @@ export function ModelSelect(props) {
|
|
|
70
71
|
width: 'unset',
|
|
71
72
|
display: 'flex',
|
|
72
73
|
alignItems: 'center'
|
|
73
|
-
} },
|
|
74
|
-
React.createElement(Typography, { variant: "caption", sx: { fontSize: '0.7rem', fontWeight: 500 } }, trans.__('No Providers'))));
|
|
74
|
+
}, children: _jsx(Typography, { variant: "caption", sx: { fontSize: '0.7rem', fontWeight: 500 }, children: trans.__('No Providers') }) }));
|
|
75
75
|
}
|
|
76
|
-
return (
|
|
77
|
-
React.createElement(TooltippedButton, { onClick: e => {
|
|
78
|
-
openMenu(e.currentTarget);
|
|
79
|
-
}, tooltip: trans.__('Current Model: %1 - %2', currentProviderLabel, currentModel), buttonProps: {
|
|
80
|
-
title: trans.__('Select AI Model'),
|
|
81
|
-
onKeyDown: e => {
|
|
82
|
-
if (e.key !== 'Enter' && e.key !== ' ') {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
76
|
+
return (_jsxs(_Fragment, { children: [_jsx(TooltippedButton, { onClick: e => {
|
|
85
77
|
openMenu(e.currentTarget);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
78
|
+
}, tooltip: trans.__('Current Model: %1 - %2', currentProviderLabel, currentModel), buttonProps: {
|
|
79
|
+
title: trans.__('Select AI Model'),
|
|
80
|
+
onKeyDown: e => {
|
|
81
|
+
if (e.key !== 'Enter' && e.key !== ' ') {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
openMenu(e.currentTarget);
|
|
85
|
+
// Stop propagation to prevent sending message
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
}
|
|
88
|
+
}, sx: {
|
|
89
|
+
minWidth: 'auto',
|
|
90
|
+
width: 'unset',
|
|
91
|
+
display: 'flex',
|
|
92
|
+
alignItems: 'center'
|
|
93
|
+
}, children: _jsx(Typography, { variant: "caption", sx: { fontSize: '0.7rem', fontWeight: 500, textTransform: 'none' }, children: currentProviderLabel }) }), _jsx(Menu, { open: menuOpen, onClose: closeMenu, anchorEl: menuAnchorEl, anchorOrigin: {
|
|
94
|
+
vertical: 'top',
|
|
95
|
+
horizontal: 'right'
|
|
96
|
+
}, transformOrigin: {
|
|
97
|
+
vertical: 'bottom',
|
|
98
|
+
horizontal: 'right'
|
|
99
|
+
}, sx: {
|
|
100
|
+
'& .MuiPaper-root': {
|
|
101
|
+
maxHeight: '300px',
|
|
102
|
+
overflowY: 'auto'
|
|
103
|
+
},
|
|
104
|
+
'& .MuiMenuItem-root': {
|
|
105
|
+
padding: '0.5em',
|
|
106
|
+
paddingRight: '2em',
|
|
107
|
+
minWidth: '200px'
|
|
108
|
+
}
|
|
109
|
+
}, children: availableModels.map(({ provider, providerLabel, isSelected }) => (_jsxs(MenuItem, { onClick: async (e) => {
|
|
110
|
+
await selectModel(provider);
|
|
111
|
+
// Prevent sending message on model selection
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
}, sx: {
|
|
114
|
+
backgroundColor: isSelected
|
|
115
|
+
? 'var(--mui-palette-primary-main)'
|
|
116
|
+
: 'transparent',
|
|
117
|
+
'&:hover': {
|
|
118
|
+
backgroundColor: isSelected
|
|
119
|
+
? 'var(--mui-palette-primary-main)'
|
|
120
|
+
: 'var(--jp-layout-color1)'
|
|
121
|
+
},
|
|
122
|
+
display: 'flex',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
gap: '8px'
|
|
125
|
+
}, children: [isSelected ? (_jsx(CheckIcon, { sx: {
|
|
126
|
+
color: 'var(--jp-ui-inverse-font-color1)',
|
|
127
|
+
fontSize: 16
|
|
128
|
+
} })) : (_jsx("div", { style: { width: '16px' } })), _jsx(Typography, { variant: "body2", component: "div", sx: {
|
|
129
|
+
fontWeight: isSelected ? 600 : 400,
|
|
130
|
+
color: isSelected
|
|
131
|
+
? 'var(--jp-ui-inverse-font-color1)'
|
|
132
|
+
: 'inherit'
|
|
133
|
+
}, children: providerLabel })] }, provider))) })] }));
|
|
139
134
|
}
|
|
140
135
|
/**
|
|
141
136
|
* Factory function returning the toolbar item for model selection.
|
|
@@ -152,7 +147,7 @@ export function createModelSelectItem(settingsModel, translator) {
|
|
|
152
147
|
settingsModel,
|
|
153
148
|
translator
|
|
154
149
|
};
|
|
155
|
-
return
|
|
150
|
+
return _jsx(ModelSelect, { ...modelSelectProps });
|
|
156
151
|
},
|
|
157
152
|
position: 0.5
|
|
158
153
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactWidget } from '@jupyterlab/ui-components';
|
|
2
2
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { IAIChatModel } from '../tokens';
|
|
5
5
|
/**
|
|
6
6
|
* Properties for the SaveButton component.
|
|
7
7
|
*/
|
|
@@ -9,7 +9,7 @@ export interface ISaveButtonProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* The chat model, used to listen for message changes for auto-save.
|
|
11
11
|
*/
|
|
12
|
-
model:
|
|
12
|
+
model: IAIChatModel;
|
|
13
13
|
/**
|
|
14
14
|
* The application language translator.
|
|
15
15
|
*/
|
|
@@ -29,3 +29,4 @@ export declare class SaveComponentWidget extends ReactWidget {
|
|
|
29
29
|
protected render(): React.ReactElement;
|
|
30
30
|
private _options;
|
|
31
31
|
}
|
|
32
|
+
//# sourceMappingURL=save-button.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { historyIcon, ReactWidget, saveIcon, ToolbarButtonComponent } from '@jupyterlab/ui-components';
|
|
2
|
-
import
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
3
4
|
const COMPONENT_CLASS = 'jp-ai-SaveButton';
|
|
4
5
|
const AUTOSAVE_BUTTON_CLASS = 'jp-ai-AutoSaveButton';
|
|
5
6
|
/**
|
|
@@ -22,9 +23,7 @@ export function SaveComponent(props) {
|
|
|
22
23
|
model.autosaveChanged.disconnect(updateAutosave);
|
|
23
24
|
};
|
|
24
25
|
}, [model]);
|
|
25
|
-
return (
|
|
26
|
-
React.createElement(ToolbarButtonComponent, { icon: saveIcon, onClick: () => model.save(), tooltip: trans.__('Save chat') }),
|
|
27
|
-
React.createElement(ToolbarButtonComponent, { className: AUTOSAVE_BUTTON_CLASS, icon: historyIcon, onClick: () => (model.autosave = !model.autosave), tooltip: trans.__('Auto-save') })));
|
|
26
|
+
return (_jsxs("div", { className: `${COMPONENT_CLASS}${autosave ? ' lm-mod-toggled' : ''}`, children: [_jsx(ToolbarButtonComponent, { icon: saveIcon, onClick: () => model.save(), tooltip: trans.__('Save chat') }), _jsx(ToolbarButtonComponent, { className: AUTOSAVE_BUTTON_CLASS, icon: historyIcon, onClick: () => (model.autosave = !model.autosave), tooltip: trans.__('Auto-save') })] }));
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* A Lumino widget wrapping the SaveButton React component.
|
|
@@ -35,7 +34,7 @@ export class SaveComponentWidget extends ReactWidget {
|
|
|
35
34
|
this._options = options;
|
|
36
35
|
}
|
|
37
36
|
render() {
|
|
38
|
-
return
|
|
37
|
+
return _jsx(SaveComponent, { ...this._options });
|
|
39
38
|
}
|
|
40
39
|
_options;
|
|
41
40
|
}
|
|
@@ -21,3 +21,4 @@ export declare function StopButton(props: IStopButtonProps): JSX.Element;
|
|
|
21
21
|
* Factory returning the stop button toolbar item.
|
|
22
22
|
*/
|
|
23
23
|
export declare function stopItem(translator: TranslationBundle): InputToolbarRegistry.IToolbarItem;
|
|
24
|
+
//# sourceMappingURL=stop-button.d.ts.map
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { TooltippedIconButton } from '@jupyter/chat';
|
|
2
3
|
import StopIcon from '@mui/icons-material/Stop';
|
|
3
|
-
import React from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* The stop button component.
|
|
6
6
|
*/
|
|
7
7
|
export function StopButton(props) {
|
|
8
8
|
const { translator: trans } = props;
|
|
9
9
|
const tooltip = trans.__('Stop streaming');
|
|
10
|
-
return (
|
|
10
|
+
return (_jsx(TooltippedIconButton, { onClick: props.stopStreaming, tooltip: tooltip, buttonProps: {
|
|
11
11
|
title: tooltip
|
|
12
12
|
}, sx: {
|
|
13
13
|
backgroundColor: 'var(--mui-palette-error-main, #d32f2f);'
|
|
14
|
-
} }
|
|
15
|
-
React.createElement(StopIcon, null)));
|
|
14
|
+
}, children: _jsx(StopIcon, {}) }));
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
17
|
* Factory returning the stop button toolbar item.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { IProviderRegistry, IToolRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { InputToolbarRegistry } from '@jupyter/chat';
|
|
2
3
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
3
|
-
import type { IAISettingsModel
|
|
4
|
+
import type { IAISettingsModel } from '../tokens';
|
|
4
5
|
/**
|
|
5
6
|
* Properties for the tool select component.
|
|
6
7
|
*/
|
|
@@ -38,3 +39,4 @@ export declare function ToolSelect(props: IToolSelectProps): JSX.Element;
|
|
|
38
39
|
* Factory function returning the toolbar item for tool selection.
|
|
39
40
|
*/
|
|
40
41
|
export declare function createToolSelectItem(toolRegistry: IToolRegistry, settingsModel: IAISettingsModel, providerRegistry: IProviderRegistry, toolsEnabled: boolean | undefined, translator: TranslationBundle): InputToolbarRegistry.IToolbarItem;
|
|
42
|
+
//# sourceMappingURL=tool-select.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createProviderTools } from '@jupyternaut/agent';
|
|
1
3
|
import { TooltippedButton } from '@jupyter/chat';
|
|
2
4
|
import BuildIcon from '@mui/icons-material/Build';
|
|
3
5
|
import CheckIcon from '@mui/icons-material/Check';
|
|
4
6
|
import { Divider, Menu, MenuItem, Tooltip, Typography } from '@mui/material';
|
|
5
|
-
import
|
|
6
|
-
import { createProviderTools } from '../providers/provider-tools';
|
|
7
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
8
|
const SELECT_ITEM_CLASS = 'jp-AIToolSelect-item';
|
|
8
9
|
/**
|
|
9
10
|
* The tool select component for choosing AI tools.
|
|
@@ -97,68 +98,54 @@ export function ToolSelect(props) {
|
|
|
97
98
|
}, [tools, selectedToolNames.length, onToolSelectionChange]);
|
|
98
99
|
// Don't render if tools are disabled or no tools available
|
|
99
100
|
if (!toolsEnabled || (tools.length === 0 && providerToolNames.length === 0)) {
|
|
100
|
-
return
|
|
101
|
+
return _jsx(_Fragment, {});
|
|
101
102
|
}
|
|
102
103
|
const selectedCount = selectedToolNames.length + providerToolNames.length;
|
|
103
104
|
const totalCount = tools.length + providerToolNames.length;
|
|
104
|
-
return (
|
|
105
|
-
React.createElement(TooltippedButton, { onClick: e => {
|
|
106
|
-
openMenu(e.currentTarget);
|
|
107
|
-
}, tooltip: trans.__('Tools (%1/%2 selected)', selectedCount.toString(), totalCount.toString()), buttonProps: {
|
|
108
|
-
...(selectedCount === 0 && {
|
|
109
|
-
variant: 'outlined'
|
|
110
|
-
}),
|
|
111
|
-
title: trans.__('Select AI Tools'),
|
|
112
|
-
onKeyDown: e => {
|
|
113
|
-
if (e.key !== 'Enter' && e.key !== ' ') {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
105
|
+
return (_jsxs(_Fragment, { children: [_jsx(TooltippedButton, { onClick: e => {
|
|
116
106
|
openMenu(e.currentTarget);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
vertical: 'bottom',
|
|
129
|
-
horizontal: 'right'
|
|
130
|
-
}, sx: {
|
|
131
|
-
'& .MuiMenuItem-root': {
|
|
132
|
-
padding: '0.5em',
|
|
133
|
-
paddingRight: '2em'
|
|
134
|
-
}
|
|
135
|
-
} },
|
|
136
|
-
tools.map(namedTool => (React.createElement(Tooltip, { key: namedTool.name, title: namedTool.tool.description || namedTool.name, placement: "left" },
|
|
137
|
-
React.createElement(MenuItem, { className: SELECT_ITEM_CLASS, onClick: e => {
|
|
138
|
-
toggleTool(namedTool.name);
|
|
139
|
-
// Prevent sending message on tool selection
|
|
107
|
+
}, tooltip: trans.__('Tools (%1/%2 selected)', selectedCount.toString(), totalCount.toString()), buttonProps: {
|
|
108
|
+
...(selectedCount === 0 && {
|
|
109
|
+
variant: 'outlined'
|
|
110
|
+
}),
|
|
111
|
+
title: trans.__('Select AI Tools'),
|
|
112
|
+
onKeyDown: e => {
|
|
113
|
+
if (e.key !== 'Enter' && e.key !== ' ') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
openMenu(e.currentTarget);
|
|
117
|
+
// Stop propagation to prevent sending message
|
|
140
118
|
e.stopPropagation();
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
119
|
+
}
|
|
120
|
+
}, sx: selectedCount === 0
|
|
121
|
+
? { backgroundColor: 'var(--jp-layout-color3)' }
|
|
122
|
+
: {}, children: _jsx(BuildIcon, { sx: { fontSize: 'small' } }) }), _jsxs(Menu, { open: menuOpen, onClose: closeMenu, anchorEl: menuAnchorEl, anchorOrigin: {
|
|
123
|
+
vertical: 'top',
|
|
124
|
+
horizontal: 'right'
|
|
125
|
+
}, transformOrigin: {
|
|
126
|
+
vertical: 'bottom',
|
|
127
|
+
horizontal: 'right'
|
|
128
|
+
}, sx: {
|
|
129
|
+
'& .MuiMenuItem-root': {
|
|
130
|
+
padding: '0.5em',
|
|
131
|
+
paddingRight: '2em'
|
|
132
|
+
}
|
|
133
|
+
}, children: [tools.map(namedTool => (_jsx(Tooltip, { title: namedTool.tool.description || namedTool.name, placement: "left", children: _jsxs(MenuItem, { className: SELECT_ITEM_CLASS, onClick: e => {
|
|
134
|
+
toggleTool(namedTool.name);
|
|
135
|
+
// Prevent sending message on tool selection
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
}, children: [selectedToolNames.includes(namedTool.name) ? (_jsx(CheckIcon, { sx: {
|
|
138
|
+
marginRight: '8px',
|
|
139
|
+
color: 'var(--jp-brand-color1, #2196F3)'
|
|
140
|
+
} })) : (_jsx("div", { style: { width: '24px', marginRight: '8px' } })), _jsx(Typography, { variant: "body2", children: namedTool.name })] }) }, namedTool.name))), providerToolNames.length > 0 && tools.length > 0 && _jsx(Divider, {}), providerToolNames.length > 0 && (_jsx(MenuItem, { disabled: true, children: _jsx(Typography, { variant: "caption", children: trans.__('Provider Tools') }) })), providerToolNames.map(toolName => {
|
|
141
|
+
return (_jsx(Tooltip, { title: trans.__('Enabled via provider settings.'), placement: "left", children: _jsxs(MenuItem, { className: SELECT_ITEM_CLASS, onClick: e => {
|
|
142
|
+
// Keep provider-managed tools read-only from this menu.
|
|
143
|
+
e.stopPropagation();
|
|
144
|
+
}, children: [_jsx(CheckIcon, { sx: {
|
|
145
|
+
marginRight: '8px',
|
|
146
|
+
color: 'text.disabled'
|
|
147
|
+
} }), _jsx(Typography, { variant: "body2", children: toolName })] }) }, toolName));
|
|
148
|
+
})] })] }));
|
|
162
149
|
}
|
|
163
150
|
/**
|
|
164
151
|
* Factory function returning the toolbar item for tool selection.
|
|
@@ -183,7 +170,7 @@ export function createToolSelectItem(toolRegistry, settingsModel, providerRegist
|
|
|
183
170
|
toolsEnabled,
|
|
184
171
|
translator
|
|
185
172
|
};
|
|
186
|
-
return
|
|
173
|
+
return _jsx(ToolSelect, { ...toolSelectProps });
|
|
187
174
|
},
|
|
188
175
|
position: 1
|
|
189
176
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { ITokenUsage } from '@jupyternaut/agent';
|
|
1
2
|
import { ReactWidget } from '@jupyterlab/ui-components';
|
|
2
3
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
3
|
-
import React from 'react';
|
|
4
4
|
import { ISignal } from '@lumino/signaling';
|
|
5
|
-
import
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { IAISettingsModel } from '../tokens';
|
|
6
7
|
/**
|
|
7
8
|
* Props for the UsageDisplay component.
|
|
8
9
|
*/
|
|
@@ -47,3 +48,4 @@ export declare class UsageWidget extends ReactWidget {
|
|
|
47
48
|
protected render(): React.ReactElement;
|
|
48
49
|
private _options;
|
|
49
50
|
}
|
|
51
|
+
//# sourceMappingURL=usage-display.d.ts.map
|