@jupyterlite/ai 0.18.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 +3 -1
- package/lib/chat-model.d.ts +46 -8
- package/lib/chat-model.js +51 -21
- 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 +1 -0
- 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 +28 -17
- package/lib/models/settings-model.d.ts +3 -1
- package/lib/rendered-message-outputarea.d.ts +1 -0
- package/lib/tokens.d.ts +18 -640
- package/lib/tokens.js +2 -31
- package/lib/widgets/ai-settings.d.ts +3 -1
- package/lib/widgets/ai-settings.js +185 -349
- package/lib/widgets/main-area-chat.d.ts +1 -0
- 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/src/chat-commands/skills.ts +2 -2
- package/src/chat-model-handler.ts +6 -4
- package/src/chat-model.ts +66 -19
- 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/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 +62 -44
- package/src/models/settings-model.ts +6 -6
- package/src/tokens.ts +23 -788
- package/src/widgets/ai-settings.tsx +14 -11
- package/src/widgets/provider-config-dialog.tsx +8 -8
- package/LICENSE +0 -30
- package/README.md +0 -49
- package/lib/agent.d.ts +0 -280
- package/lib/agent.js +0 -1103
- 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-model-info.d.ts +0 -8
- package/lib/providers/generated-model-info.js +0 -502
- package/lib/providers/model-info.d.ts +0 -6
- package/lib/providers/model-info.js +0 -91
- 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 -1431
- package/src/icons.ts +0 -11
- package/src/providers/built-in-providers.ts +0 -241
- package/src/providers/generated-model-info.ts +0 -508
- package/src/providers/model-info.ts +0 -145
- 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
package/package.json
CHANGED
|
@@ -1,261 +1,114 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
"rimraf": "^5.0.1",
|
|
113
|
-
"source-map-loader": "^1.0.2",
|
|
114
|
-
"style-loader": "^3.3.1",
|
|
115
|
-
"stylelint": "^15.10.1",
|
|
116
|
-
"stylelint-config-recommended": "^13.0.0",
|
|
117
|
-
"stylelint-config-standard": "^34.0.0",
|
|
118
|
-
"stylelint-csstree-validator": "^3.0.0",
|
|
119
|
-
"stylelint-prettier": "^4.0.0",
|
|
120
|
-
"typescript": "~5.8.0",
|
|
121
|
-
"yjs": "^13.5.0"
|
|
122
|
-
},
|
|
123
|
-
"sideEffects": [
|
|
124
|
-
"style/*.css",
|
|
125
|
-
"style/index.js"
|
|
126
|
-
],
|
|
127
|
-
"styleModule": "style/index.js",
|
|
128
|
-
"publishConfig": {
|
|
129
|
-
"access": "public"
|
|
130
|
-
},
|
|
131
|
-
"jupyterlab": {
|
|
132
|
-
"extension": true,
|
|
133
|
-
"outputDir": "jupyterlite_ai/labextension",
|
|
134
|
-
"schemaDir": "schema",
|
|
135
|
-
"sharedPackages": {
|
|
136
|
-
"@jupyter/chat": {
|
|
137
|
-
"bundled": true,
|
|
138
|
-
"singleton": true
|
|
139
|
-
},
|
|
140
|
-
"jupyter-chat-components": {
|
|
141
|
-
"bundled": false,
|
|
142
|
-
"singleton": true
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
"eslintIgnore": [
|
|
147
|
-
"node_modules",
|
|
148
|
-
"dist",
|
|
149
|
-
"coverage",
|
|
150
|
-
"**/*.d.ts",
|
|
151
|
-
"tests",
|
|
152
|
-
"**/__tests__",
|
|
153
|
-
"ui-tests",
|
|
154
|
-
".venv",
|
|
155
|
-
"webpack.config.js"
|
|
156
|
-
],
|
|
157
|
-
"eslintConfig": {
|
|
158
|
-
"extends": [
|
|
159
|
-
"eslint:recommended",
|
|
160
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
161
|
-
"plugin:@typescript-eslint/recommended",
|
|
162
|
-
"plugin:prettier/recommended"
|
|
163
|
-
],
|
|
164
|
-
"parser": "@typescript-eslint/parser",
|
|
165
|
-
"parserOptions": {
|
|
166
|
-
"project": "tsconfig.json",
|
|
167
|
-
"sourceType": "module"
|
|
168
|
-
},
|
|
169
|
-
"plugins": [
|
|
170
|
-
"@typescript-eslint"
|
|
171
|
-
],
|
|
172
|
-
"rules": {
|
|
173
|
-
"@typescript-eslint/naming-convention": [
|
|
174
|
-
"error",
|
|
175
|
-
{
|
|
176
|
-
"selector": "interface",
|
|
177
|
-
"format": [
|
|
178
|
-
"PascalCase"
|
|
179
|
-
],
|
|
180
|
-
"custom": {
|
|
181
|
-
"regex": "^I[A-Z]",
|
|
182
|
-
"match": true
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
],
|
|
186
|
-
"@typescript-eslint/no-unused-vars": [
|
|
187
|
-
"warn",
|
|
188
|
-
{
|
|
189
|
-
"args": "none"
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
193
|
-
"@typescript-eslint/no-namespace": "off",
|
|
194
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
195
|
-
"@typescript-eslint/quotes": [
|
|
196
|
-
"error",
|
|
197
|
-
"single",
|
|
198
|
-
{
|
|
199
|
-
"avoidEscape": true,
|
|
200
|
-
"allowTemplateLiterals": false
|
|
201
|
-
}
|
|
202
|
-
],
|
|
203
|
-
"curly": [
|
|
204
|
-
"error",
|
|
205
|
-
"all"
|
|
206
|
-
],
|
|
207
|
-
"eqeqeq": "error",
|
|
208
|
-
"prefer-arrow-callback": "error",
|
|
209
|
-
"no-restricted-imports": [
|
|
210
|
-
"error",
|
|
211
|
-
{
|
|
212
|
-
"paths": [
|
|
213
|
-
{
|
|
214
|
-
"name": "@mui/icons-material",
|
|
215
|
-
"message": "Please import icons using path imports, e.g. `import AddIcon from '@mui/icons-material/Add'`"
|
|
216
|
-
}
|
|
217
|
-
],
|
|
218
|
-
"patterns": [
|
|
219
|
-
{
|
|
220
|
-
"group": [
|
|
221
|
-
"@mui/*/*/*"
|
|
222
|
-
],
|
|
223
|
-
"message": "3rd level imports in mui are considered private"
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
}
|
|
227
|
-
]
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
"prettier": {
|
|
231
|
-
"singleQuote": true,
|
|
232
|
-
"trailingComma": "none",
|
|
233
|
-
"arrowParens": "avoid",
|
|
234
|
-
"endOfLine": "auto",
|
|
235
|
-
"overrides": [
|
|
236
|
-
{
|
|
237
|
-
"files": "package.json",
|
|
238
|
-
"options": {
|
|
239
|
-
"tabWidth": 4
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
"stylelint": {
|
|
245
|
-
"extends": [
|
|
246
|
-
"stylelint-config-recommended",
|
|
247
|
-
"stylelint-config-standard",
|
|
248
|
-
"stylelint-prettier/recommended"
|
|
249
|
-
],
|
|
250
|
-
"plugins": [
|
|
251
|
-
"stylelint-csstree-validator"
|
|
252
|
-
],
|
|
253
|
-
"rules": {
|
|
254
|
-
"csstree/validator": true,
|
|
255
|
-
"property-no-vendor-prefix": null,
|
|
256
|
-
"selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$|^Mui[A-Z]",
|
|
257
|
-
"selector-no-vendor-prefix": null,
|
|
258
|
-
"value-no-vendor-prefix": null
|
|
259
|
-
}
|
|
2
|
+
"name": "@jupyterlite/ai",
|
|
3
|
+
"version": "0.19.0",
|
|
4
|
+
"description": "AI code completions and chat for JupyterLite",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jupyter",
|
|
7
|
+
"jupyterlab",
|
|
8
|
+
"jupyterlab-extension"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/jupyterlite/ai",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/jupyterlite/ai/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "BSD-3-Clause",
|
|
15
|
+
"author": "JupyterLite Contributors",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,md}",
|
|
18
|
+
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
|
|
19
|
+
"src/**/*.{ts,tsx}",
|
|
20
|
+
"schema/*.json"
|
|
21
|
+
],
|
|
22
|
+
"main": "lib/index.js",
|
|
23
|
+
"types": "lib/index.d.ts",
|
|
24
|
+
"style": "style/index.css",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/jupyterlite/ai.git",
|
|
28
|
+
"directory": "packages/ai"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "echo 'Building @jupyterlite/ai' && jlpm build:lib && jlpm build:labextension:dev",
|
|
32
|
+
"build:dev": "echo 'Building @jupyterlite/ai' && jlpm build:lib && jlpm build:labextension:dev",
|
|
33
|
+
"build:prod": "echo 'Building @jupyterlite/ai' && jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
|
|
34
|
+
"build:labextension": "jupyter labextension build .",
|
|
35
|
+
"build:labextension:dev": "jupyter labextension build --development True .",
|
|
36
|
+
"build:lib": "tsc --sourceMap",
|
|
37
|
+
"build:lib:prod": "tsc",
|
|
38
|
+
"clean": "jlpm clean:lib",
|
|
39
|
+
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
|
40
|
+
"install:extension": "jlpm build",
|
|
41
|
+
"watch": "run-p watch:src watch:labextension",
|
|
42
|
+
"watch:src": "tsc -w --sourceMap",
|
|
43
|
+
"watch:labextension": "jupyter labextension watch ."
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@jupyter/chat": "^0.21.1",
|
|
47
|
+
"@jupyter/ydoc": "^3.1.0",
|
|
48
|
+
"@jupyterlab/application": "^4.5.8",
|
|
49
|
+
"@jupyterlab/apputils": "^4.6.8",
|
|
50
|
+
"@jupyterlab/completer": "^4.5.8",
|
|
51
|
+
"@jupyterlab/coreutils": "^6.5.8",
|
|
52
|
+
"@jupyterlab/docmanager": "^4.5.8",
|
|
53
|
+
"@jupyterlab/docregistry": "^4.5.8",
|
|
54
|
+
"@jupyterlab/filebrowser": "^4.5.8",
|
|
55
|
+
"@jupyterlab/nbformat": "^4.5.8",
|
|
56
|
+
"@jupyterlab/notebook": "^4.5.8",
|
|
57
|
+
"@jupyterlab/rendermime": "^4.5.8",
|
|
58
|
+
"@jupyterlab/services": "^7.5.8",
|
|
59
|
+
"@jupyterlab/settingregistry": "^4.5.8",
|
|
60
|
+
"@jupyterlab/statusbar": "^4.5.8",
|
|
61
|
+
"@jupyterlab/translation": "^4.5.8",
|
|
62
|
+
"@jupyterlab/ui-components": "^4.5.8",
|
|
63
|
+
"@jupyternaut/agent": "^0.19.0",
|
|
64
|
+
"@lumino/commands": "^2.3.2",
|
|
65
|
+
"@lumino/coreutils": "^2.2.1",
|
|
66
|
+
"@lumino/disposable": "^2.1.4",
|
|
67
|
+
"@lumino/polling": "^2.1.4",
|
|
68
|
+
"@lumino/signaling": "^2.1.4",
|
|
69
|
+
"@lumino/widgets": "^2.7.1",
|
|
70
|
+
"@mui/icons-material": "^7",
|
|
71
|
+
"@mui/material": "^7",
|
|
72
|
+
"ai": "^6.0.116",
|
|
73
|
+
"jupyter-chat-components": "^0.6.0",
|
|
74
|
+
"jupyter-secrets-manager": "^0.5.0",
|
|
75
|
+
"react": "^18.3.1",
|
|
76
|
+
"yaml": "^2.8.1"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@jupyterlab/builder": "^4.0.0",
|
|
80
|
+
"@jupyterlab/testutils": "^4.0.0",
|
|
81
|
+
"@types/json-schema": "^7.0.11",
|
|
82
|
+
"@types/node": "^24.3.0",
|
|
83
|
+
"@types/react": "^18.0.26",
|
|
84
|
+
"@types/react-addons-linked-state-mixin": "^0.14.22",
|
|
85
|
+
"css-loader": "^6.7.1",
|
|
86
|
+
"npm-run-all2": "^7.0.1",
|
|
87
|
+
"rimraf": "^5.0.1",
|
|
88
|
+
"source-map-loader": "^1.0.2",
|
|
89
|
+
"typescript": "~5.8.0"
|
|
90
|
+
},
|
|
91
|
+
"sideEffects": [
|
|
92
|
+
"style/*.css",
|
|
93
|
+
"style/index.js"
|
|
94
|
+
],
|
|
95
|
+
"styleModule": "style/index.js",
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public"
|
|
98
|
+
},
|
|
99
|
+
"jupyterlab": {
|
|
100
|
+
"extension": true,
|
|
101
|
+
"outputDir": "../../jupyterlite_ai/labextension",
|
|
102
|
+
"schemaDir": "schema",
|
|
103
|
+
"sharedPackages": {
|
|
104
|
+
"@jupyter/chat": {
|
|
105
|
+
"bundled": true,
|
|
106
|
+
"singleton": true
|
|
107
|
+
},
|
|
108
|
+
"jupyter-chat-components": {
|
|
109
|
+
"bundled": false,
|
|
110
|
+
"singleton": true
|
|
111
|
+
}
|
|
260
112
|
}
|
|
113
|
+
}
|
|
261
114
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { ISkillRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { ChatCommand, IChatCommandProvider, IInputModel } from '@jupyter/chat';
|
|
2
|
-
|
|
3
3
|
import { CommandRegistry } from '@lumino/commands';
|
|
4
4
|
|
|
5
5
|
import { AIChatModel } from '../chat-model';
|
|
6
|
-
import { CommandIds
|
|
6
|
+
import { CommandIds } from '../tokens';
|
|
7
7
|
|
|
8
8
|
export class SkillsCommandProvider implements IChatCommandProvider {
|
|
9
9
|
constructor(options: SkillsCommandProvider.IOptions) {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IAgentManagerFactory,
|
|
3
|
+
IProviderRegistry,
|
|
4
|
+
IToolRegistry
|
|
5
|
+
} from '@jupyternaut/agent';
|
|
1
6
|
import { ActiveCellManager } from '@jupyter/chat';
|
|
2
7
|
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
3
8
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
@@ -5,13 +10,10 @@ import { Contents } from '@jupyterlab/services';
|
|
|
5
10
|
|
|
6
11
|
import { AIChatModel } from './chat-model';
|
|
7
12
|
import type {
|
|
8
|
-
IAgentManagerFactory,
|
|
9
13
|
IAIChatModel,
|
|
10
14
|
IAISettingsModel,
|
|
11
15
|
IChatModelHandler,
|
|
12
|
-
ICreateChatOptions
|
|
13
|
-
IProviderRegistry,
|
|
14
|
-
IToolRegistry
|
|
16
|
+
ICreateChatOptions
|
|
15
17
|
} from './tokens';
|
|
16
18
|
|
|
17
19
|
/**
|
package/src/chat-model.ts
CHANGED
|
@@ -26,6 +26,14 @@ import { IRenderMime } from '@jupyterlab/rendermime';
|
|
|
26
26
|
|
|
27
27
|
import { Contents } from '@jupyterlab/services';
|
|
28
28
|
|
|
29
|
+
import { AI_AVATAR } from '@jupyternaut/agent';
|
|
30
|
+
|
|
31
|
+
import type {
|
|
32
|
+
IAgentManager,
|
|
33
|
+
IProviderRegistry,
|
|
34
|
+
ITokenUsage
|
|
35
|
+
} from '@jupyternaut/agent';
|
|
36
|
+
|
|
29
37
|
import { UUID } from '@lumino/coreutils';
|
|
30
38
|
|
|
31
39
|
import { Debouncer } from '@lumino/polling';
|
|
@@ -34,21 +42,13 @@ import { ISignal, Signal } from '@lumino/signaling';
|
|
|
34
42
|
|
|
35
43
|
import type { UserContent, ImagePart, FilePart, ModelMessage } from 'ai';
|
|
36
44
|
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
import type {
|
|
40
|
-
IAgentManager,
|
|
41
|
-
IAIChatModel,
|
|
42
|
-
IAISettingsModel,
|
|
43
|
-
IProviderRegistry,
|
|
44
|
-
ITokenUsage
|
|
45
|
-
} from './tokens';
|
|
45
|
+
import type { IAIChatModel, IAISettingsModel } from './tokens';
|
|
46
46
|
|
|
47
47
|
import {
|
|
48
48
|
modelSupportsAudio,
|
|
49
49
|
modelSupportsImages,
|
|
50
50
|
modelSupportsPdf
|
|
51
|
-
} from '
|
|
51
|
+
} from '@jupyternaut/agent';
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Tool call status types.
|
|
@@ -273,7 +273,11 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
273
273
|
stopStreaming: () => this.stopStreaming(),
|
|
274
274
|
clearMessages: () => this.clearMessages(),
|
|
275
275
|
agentManager: this._agentManager,
|
|
276
|
-
addSystemMessage: (body: string) => this._addSystemMessage(body)
|
|
276
|
+
addSystemMessage: (body: string) => this._addSystemMessage(body),
|
|
277
|
+
removeQueuedMessage: (id: string) => this.removeQueuedMessage(id),
|
|
278
|
+
reorderQueuedMessages: (ids: string[]) => this.reorderQueuedMessages(ids),
|
|
279
|
+
editQueuedMessage: (id: string, body: string) =>
|
|
280
|
+
this.editQueuedMessage(id, body)
|
|
277
281
|
};
|
|
278
282
|
}
|
|
279
283
|
|
|
@@ -438,7 +442,9 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
438
442
|
|
|
439
443
|
if (
|
|
440
444
|
this._settingsModel.config.autoTitle &&
|
|
441
|
-
(this.messages.
|
|
445
|
+
(this.messages.filter(msg => msg.sender.username !== 'ai-assistant')
|
|
446
|
+
.length <= 5 ||
|
|
447
|
+
this.title === null)
|
|
442
448
|
) {
|
|
443
449
|
try {
|
|
444
450
|
this.title = await this.requestTitle();
|
|
@@ -528,8 +534,32 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
528
534
|
* @param messageId The ID of the queued message to remove
|
|
529
535
|
*/
|
|
530
536
|
removeQueuedMessage(messageId: string): void {
|
|
531
|
-
this.
|
|
532
|
-
|
|
537
|
+
this.messageQueue = this._messageQueue.filter(msg => msg.id !== messageId);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Reorders queued messages by their IDs.
|
|
542
|
+
* @param messageIds Array of message IDs in the desired order
|
|
543
|
+
*/
|
|
544
|
+
reorderQueuedMessages(messageIds: string[]): void {
|
|
545
|
+
const byId = new Map(this._messageQueue.map(m => [m.id, m]));
|
|
546
|
+
this.messageQueue = messageIds
|
|
547
|
+
.map(id => byId.get(id))
|
|
548
|
+
.filter((m): m is Private.IQueuedItem => m !== undefined);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Edits a queued message by its ID.
|
|
553
|
+
* @param messageId The ID of the queued message to edit
|
|
554
|
+
* @param newBody The new body of the message
|
|
555
|
+
*/
|
|
556
|
+
editQueuedMessage(messageId: string, newBody: string): void {
|
|
557
|
+
const queue = [...this._messageQueue];
|
|
558
|
+
const index = queue.findIndex(m => m.id === messageId);
|
|
559
|
+
if (index !== -1) {
|
|
560
|
+
queue[index] = { ...queue[index], body: newBody };
|
|
561
|
+
this.messageQueue = queue;
|
|
562
|
+
}
|
|
533
563
|
}
|
|
534
564
|
|
|
535
565
|
/**
|
|
@@ -600,7 +630,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
600
630
|
);
|
|
601
631
|
}
|
|
602
632
|
} else if (!silent) {
|
|
603
|
-
console.log(`Provider not
|
|
633
|
+
console.log(`Provider not provided when restoring ${filepath}.`);
|
|
604
634
|
}
|
|
605
635
|
|
|
606
636
|
const messages: IMessageContent[] = content.messages.map(message => {
|
|
@@ -855,6 +885,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
855
885
|
this.messageAdded(aiMessage);
|
|
856
886
|
this._currentStreamingMessage =
|
|
857
887
|
this.messages.find(message => message.id === aiMessage.id) ?? null;
|
|
888
|
+
this._updateQueueUI();
|
|
858
889
|
}
|
|
859
890
|
|
|
860
891
|
/**
|
|
@@ -1023,6 +1054,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
1023
1054
|
};
|
|
1024
1055
|
|
|
1025
1056
|
this.messageAdded(toolCallMessage);
|
|
1057
|
+
this._updateQueueUI();
|
|
1026
1058
|
}
|
|
1027
1059
|
|
|
1028
1060
|
/**
|
|
@@ -1099,6 +1131,7 @@ export class AIChatModel extends AbstractChatModel implements IAIChatModel {
|
|
|
1099
1131
|
type: 'msg',
|
|
1100
1132
|
raw_time: false
|
|
1101
1133
|
});
|
|
1134
|
+
this._updateQueueUI();
|
|
1102
1135
|
}
|
|
1103
1136
|
|
|
1104
1137
|
/**
|
|
@@ -1241,11 +1274,13 @@ namespace Private {
|
|
|
1241
1274
|
| nbformat.IDisplayUpdate
|
|
1242
1275
|
| nbformat.IExecuteResult;
|
|
1243
1276
|
|
|
1244
|
-
const isPlainObject = (
|
|
1277
|
+
export const isPlainObject = (
|
|
1278
|
+
value: unknown
|
|
1279
|
+
): value is Record<string, unknown> => {
|
|
1245
1280
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1246
1281
|
};
|
|
1247
1282
|
|
|
1248
|
-
const isDisplayOutput = (value: unknown): value is IDisplayOutput => {
|
|
1283
|
+
export const isDisplayOutput = (value: unknown): value is IDisplayOutput => {
|
|
1249
1284
|
if (!isPlainObject(value)) {
|
|
1250
1285
|
return false;
|
|
1251
1286
|
}
|
|
@@ -1258,7 +1293,7 @@ namespace Private {
|
|
|
1258
1293
|
);
|
|
1259
1294
|
};
|
|
1260
1295
|
|
|
1261
|
-
const toMimeBundle = (
|
|
1296
|
+
export const toMimeBundle = (
|
|
1262
1297
|
value: IDisplayOutput,
|
|
1263
1298
|
trustedMimeTypes: ReadonlySet<string>
|
|
1264
1299
|
): IMimeModelBody | null => {
|
|
@@ -1286,7 +1321,7 @@ namespace Private {
|
|
|
1286
1321
|
* Tool outputs are not guaranteed to be raw Jupyter IOPub messages; they are
|
|
1287
1322
|
* often wrapped objects (for example `{ success, result: { outputs: [...] } }`).
|
|
1288
1323
|
*/
|
|
1289
|
-
const toDisplayOutputs = (value: unknown): IDisplayOutput[] => {
|
|
1324
|
+
export const toDisplayOutputs = (value: unknown): IDisplayOutput[] => {
|
|
1290
1325
|
if (isDisplayOutput(value)) {
|
|
1291
1326
|
return [value];
|
|
1292
1327
|
}
|
|
@@ -1833,6 +1868,18 @@ export namespace AIChatModel {
|
|
|
1833
1868
|
* The agent manager of the chat.
|
|
1834
1869
|
*/
|
|
1835
1870
|
agentManager: IAgentManager;
|
|
1871
|
+
/**
|
|
1872
|
+
* Removes a queued message by its ID.
|
|
1873
|
+
*/
|
|
1874
|
+
removeQueuedMessage: (id: string) => void;
|
|
1875
|
+
/**
|
|
1876
|
+
* Reorders queued messages by their IDs.
|
|
1877
|
+
*/
|
|
1878
|
+
reorderQueuedMessages: (ids: string[]) => void;
|
|
1879
|
+
/**
|
|
1880
|
+
* Edits a queued message by its ID.
|
|
1881
|
+
*/
|
|
1882
|
+
editQueuedMessage: (id: string, body: string) => void;
|
|
1836
1883
|
}
|
|
1837
1884
|
|
|
1838
1885
|
/**
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCompletionModel,
|
|
3
|
+
IProviderRegistry,
|
|
4
|
+
SECRETS_NAMESPACE
|
|
5
|
+
} from '@jupyternaut/agent';
|
|
1
6
|
import {
|
|
2
7
|
CompletionHandler,
|
|
3
8
|
IInlineCompletionContext,
|
|
@@ -8,12 +13,7 @@ import { NotebookPanel } from '@jupyterlab/notebook';
|
|
|
8
13
|
import { generateText, type LanguageModel } from 'ai';
|
|
9
14
|
import { ISecretsManager } from 'jupyter-secrets-manager';
|
|
10
15
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
type IAISettingsModel,
|
|
14
|
-
SECRETS_NAMESPACE,
|
|
15
|
-
type IProviderRegistry
|
|
16
|
-
} from '../tokens';
|
|
16
|
+
import type { IAISettingsModel } from '../tokens';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Configuration interface for provider-specific completion behavior
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
import { ReactWidget } from '@jupyterlab/ui-components';
|
|
3
3
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
4
|
-
import { jupyternautIcon } from '
|
|
4
|
+
import { jupyternautIcon } from '@jupyternaut/agent';
|
|
5
5
|
import type { IAISettingsModel } from '../tokens';
|
|
6
6
|
|
|
7
7
|
const COMPLETION_STATUS_CLASS = 'jp-ai-completion-status';
|
|
@@ -2,7 +2,7 @@ import { InputToolbarRegistry, TooltippedButton } from '@jupyter/chat';
|
|
|
2
2
|
import type { TranslationBundle } from '@jupyterlab/translation';
|
|
3
3
|
import CheckIcon from '@mui/icons-material/Check';
|
|
4
4
|
import { Menu, MenuItem, Typography } from '@mui/material';
|
|
5
|
-
import
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
6
|
import { AIChatModel } from '../chat-model';
|
|
7
7
|
import type { IAISettingsModel } from '../tokens';
|
|
8
8
|
|