@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ISkillRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { ChatCommand, IChatCommandProvider, IInputModel } from '@jupyter/chat';
|
|
2
3
|
import { CommandRegistry } from '@lumino/commands';
|
|
3
|
-
import { ISkillRegistry } from '../tokens';
|
|
4
4
|
export declare class SkillsCommandProvider implements IChatCommandProvider {
|
|
5
5
|
constructor(options: SkillsCommandProvider.IOptions);
|
|
6
6
|
id: string;
|
|
@@ -17,3 +17,4 @@ export declare namespace SkillsCommandProvider {
|
|
|
17
17
|
commands: CommandRegistry;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { IAgentManagerFactory, IProviderRegistry, IToolRegistry } from '@jupyternaut/agent';
|
|
1
2
|
import { ActiveCellManager } from '@jupyter/chat';
|
|
2
3
|
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
3
4
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
4
5
|
import { Contents } from '@jupyterlab/services';
|
|
5
|
-
import type {
|
|
6
|
+
import type { IAIChatModel, IAISettingsModel, IChatModelHandler, ICreateChatOptions } from './tokens';
|
|
6
7
|
/**
|
|
7
8
|
* The chat model handler.
|
|
8
9
|
*/
|
|
@@ -59,3 +60,4 @@ export declare namespace ChatModelHandler {
|
|
|
59
60
|
contentsManager?: Contents.IManager;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
63
|
+
//# sourceMappingURL=chat-model-handler.d.ts.map
|
package/lib/chat-model.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AbstractChatModel, IActiveCellManager, IAttachment, IChatContext, IMessageContent, IMimeModelBody, INewMessage, IUser } from '@jupyter/chat';
|
|
2
2
|
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
3
|
+
import * as nbformat from '@jupyterlab/nbformat';
|
|
3
4
|
import { Contents } from '@jupyterlab/services';
|
|
5
|
+
import type { IAgentManager, IProviderRegistry, ITokenUsage } from '@jupyternaut/agent';
|
|
4
6
|
import { ISignal } from '@lumino/signaling';
|
|
5
7
|
import type { UserContent } from 'ai';
|
|
6
|
-
import type {
|
|
8
|
+
import type { IAIChatModel, IAISettingsModel } from './tokens';
|
|
7
9
|
/**
|
|
8
10
|
* AI Chat Model implementation that provides chat functionality tool integration,
|
|
9
11
|
* and MCP server support.
|
|
@@ -107,6 +109,17 @@ export declare class AIChatModel extends AbstractChatModel implements IAIChatMod
|
|
|
107
109
|
* @param messageId The ID of the queued message to remove
|
|
108
110
|
*/
|
|
109
111
|
removeQueuedMessage(messageId: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Reorders queued messages by their IDs.
|
|
114
|
+
* @param messageIds Array of message IDs in the desired order
|
|
115
|
+
*/
|
|
116
|
+
reorderQueuedMessages(messageIds: string[]): void;
|
|
117
|
+
/**
|
|
118
|
+
* Edits a queued message by its ID.
|
|
119
|
+
* @param messageId The ID of the queued message to edit
|
|
120
|
+
* @param newBody The new body of the message
|
|
121
|
+
*/
|
|
122
|
+
editQueuedMessage(messageId: string, newBody: string): void;
|
|
110
123
|
/**
|
|
111
124
|
* Save the chat as json file.
|
|
112
125
|
*/
|
|
@@ -233,18 +246,29 @@ export declare class AIChatModel extends AbstractChatModel implements IAIChatMod
|
|
|
233
246
|
private _titleChanged;
|
|
234
247
|
}
|
|
235
248
|
declare namespace Private {
|
|
236
|
-
interface IQueuedItem {
|
|
249
|
+
export interface IQueuedItem {
|
|
237
250
|
id: string;
|
|
238
251
|
body: string;
|
|
239
252
|
_originalMsg: IMessageContent;
|
|
240
253
|
}
|
|
254
|
+
type IDisplayOutput = nbformat.IDisplayData | nbformat.IDisplayUpdate | nbformat.IExecuteResult;
|
|
255
|
+
export const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
256
|
+
export const isDisplayOutput: (value: unknown) => value is IDisplayOutput;
|
|
257
|
+
export const toMimeBundle: (value: IDisplayOutput, trustedMimeTypes: ReadonlySet<string>) => IMimeModelBody | null;
|
|
258
|
+
/**
|
|
259
|
+
* Normalize arbitrary tool payloads into canonical display outputs.
|
|
260
|
+
*
|
|
261
|
+
* Tool outputs are not guaranteed to be raw Jupyter IOPub messages; they are
|
|
262
|
+
* often wrapped objects (for example `{ success, result: { outputs: [...] } }`).
|
|
263
|
+
*/
|
|
264
|
+
export const toDisplayOutputs: (value: unknown) => IDisplayOutput[];
|
|
241
265
|
/**
|
|
242
266
|
* Extract rendermime-ready mime bundles from arbitrary tool results.
|
|
243
267
|
*/
|
|
244
|
-
function extractMimeBundlesFromUnknown(content: unknown, options?: {
|
|
268
|
+
export function extractMimeBundlesFromUnknown(content: unknown, options?: {
|
|
245
269
|
trustedMimeTypes?: ReadonlyArray<string>;
|
|
246
270
|
}): IMimeModelBody[];
|
|
247
|
-
function formatToolOutput(outputData: unknown): string;
|
|
271
|
+
export function formatToolOutput(outputData: unknown): string;
|
|
248
272
|
/**
|
|
249
273
|
* Processes file attachments and returns the message content with the attachments.
|
|
250
274
|
* @param attachments Array of file attachments to process
|
|
@@ -255,28 +279,29 @@ declare namespace Private {
|
|
|
255
279
|
* @param supportsAudio Whether the model supports audio
|
|
256
280
|
* @returns Enhanced message content
|
|
257
281
|
*/
|
|
258
|
-
function processAttachments(attachments: IAttachment[], documentManager: IDocumentManager | null | undefined, body: string, supportsImages: boolean, supportsPdf: boolean, supportsAudio: boolean): Promise<UserContent>;
|
|
282
|
+
export function processAttachments(attachments: IAttachment[], documentManager: IDocumentManager | null | undefined, body: string, supportsImages: boolean, supportsPdf: boolean, supportsAudio: boolean): Promise<UserContent>;
|
|
259
283
|
/**
|
|
260
284
|
* Reads a binary attachment and returns its base64-encoded content.
|
|
261
285
|
* @param attachment The attachment to read
|
|
262
286
|
* @param documentManager Optional document manager for file operations
|
|
263
287
|
* @returns Base64 string or null if unable to read
|
|
264
288
|
*/
|
|
265
|
-
function readBinaryAttachment(attachment: IAttachment, documentManager: IDocumentManager | null | undefined): Promise<string | null>;
|
|
289
|
+
export function readBinaryAttachment(attachment: IAttachment, documentManager: IDocumentManager | null | undefined): Promise<string | null>;
|
|
266
290
|
/**
|
|
267
291
|
* Reads the content of a notebook cell.
|
|
268
292
|
* @param attachment The notebook attachment to read
|
|
269
293
|
* @param documentManager Optional document manager for file operations
|
|
270
294
|
* @returns Cell content as string or null if unable to read
|
|
271
295
|
*/
|
|
272
|
-
function readNotebookCells(attachment: IAttachment, documentManager: IDocumentManager | null | undefined): Promise<string | null>;
|
|
296
|
+
export function readNotebookCells(attachment: IAttachment, documentManager: IDocumentManager | null | undefined): Promise<string | null>;
|
|
273
297
|
/**
|
|
274
298
|
* Reads the content of a file attachment.
|
|
275
299
|
* @param attachment The file attachment to read
|
|
276
300
|
* @param documentManager Optional document manager for file operations
|
|
277
301
|
* @returns File content as string or null if unable to read
|
|
278
302
|
*/
|
|
279
|
-
function readFileAttachment(attachment: IAttachment, documentManager: IDocumentManager | null | undefined): Promise<string | null>;
|
|
303
|
+
export function readFileAttachment(attachment: IAttachment, documentManager: IDocumentManager | null | undefined): Promise<string | null>;
|
|
304
|
+
export {};
|
|
280
305
|
}
|
|
281
306
|
/**
|
|
282
307
|
* Namespace containing types and interfaces for AIChatModel.
|
|
@@ -339,6 +364,18 @@ export declare namespace AIChatModel {
|
|
|
339
364
|
* The agent manager of the chat.
|
|
340
365
|
*/
|
|
341
366
|
agentManager: IAgentManager;
|
|
367
|
+
/**
|
|
368
|
+
* Removes a queued message by its ID.
|
|
369
|
+
*/
|
|
370
|
+
removeQueuedMessage: (id: string) => void;
|
|
371
|
+
/**
|
|
372
|
+
* Reorders queued messages by their IDs.
|
|
373
|
+
*/
|
|
374
|
+
reorderQueuedMessages: (ids: string[]) => void;
|
|
375
|
+
/**
|
|
376
|
+
* Edits a queued message by its ID.
|
|
377
|
+
*/
|
|
378
|
+
editQueuedMessage: (id: string, body: string) => void;
|
|
342
379
|
}
|
|
343
380
|
/**
|
|
344
381
|
* The exported chat format.
|
|
@@ -380,3 +417,4 @@ export declare namespace AIChatModel {
|
|
|
380
417
|
};
|
|
381
418
|
}
|
|
382
419
|
export {};
|
|
420
|
+
//# sourceMappingURL=chat-model.d.ts.map
|
package/lib/chat-model.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AbstractChatModel } from '@jupyter/chat';
|
|
2
2
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
3
3
|
import * as nbformat from '@jupyterlab/nbformat';
|
|
4
|
+
import { AI_AVATAR } from '@jupyternaut/agent';
|
|
4
5
|
import { UUID } from '@lumino/coreutils';
|
|
5
6
|
import { Debouncer } from '@lumino/polling';
|
|
6
7
|
import { Signal } from '@lumino/signaling';
|
|
7
|
-
import {
|
|
8
|
-
import { modelSupportsAudio, modelSupportsImages, modelSupportsPdf } from './providers/model-info';
|
|
8
|
+
import { modelSupportsAudio, modelSupportsImages, modelSupportsPdf } from '@jupyternaut/agent';
|
|
9
9
|
/**
|
|
10
10
|
* AI Chat Model implementation that provides chat functionality tool integration,
|
|
11
11
|
* and MCP server support.
|
|
@@ -151,7 +151,10 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
151
151
|
stopStreaming: () => this.stopStreaming(),
|
|
152
152
|
clearMessages: () => this.clearMessages(),
|
|
153
153
|
agentManager: this._agentManager,
|
|
154
|
-
addSystemMessage: (body) => this._addSystemMessage(body)
|
|
154
|
+
addSystemMessage: (body) => this._addSystemMessage(body),
|
|
155
|
+
removeQueuedMessage: (id) => this.removeQueuedMessage(id),
|
|
156
|
+
reorderQueuedMessages: (ids) => this.reorderQueuedMessages(ids),
|
|
157
|
+
editQueuedMessage: (id, body) => this.editQueuedMessage(id, body)
|
|
155
158
|
};
|
|
156
159
|
}
|
|
157
160
|
/**
|
|
@@ -284,7 +287,9 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
284
287
|
finally {
|
|
285
288
|
this._drainQueue();
|
|
286
289
|
if (this._settingsModel.config.autoTitle &&
|
|
287
|
-
(this.messages.
|
|
290
|
+
(this.messages.filter(msg => msg.sender.username !== 'ai-assistant')
|
|
291
|
+
.length <= 5 ||
|
|
292
|
+
this.title === null)) {
|
|
288
293
|
try {
|
|
289
294
|
this.title = await this.requestTitle();
|
|
290
295
|
}
|
|
@@ -363,8 +368,30 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
363
368
|
* @param messageId The ID of the queued message to remove
|
|
364
369
|
*/
|
|
365
370
|
removeQueuedMessage(messageId) {
|
|
366
|
-
this.
|
|
367
|
-
|
|
371
|
+
this.messageQueue = this._messageQueue.filter(msg => msg.id !== messageId);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Reorders queued messages by their IDs.
|
|
375
|
+
* @param messageIds Array of message IDs in the desired order
|
|
376
|
+
*/
|
|
377
|
+
reorderQueuedMessages(messageIds) {
|
|
378
|
+
const byId = new Map(this._messageQueue.map(m => [m.id, m]));
|
|
379
|
+
this.messageQueue = messageIds
|
|
380
|
+
.map(id => byId.get(id))
|
|
381
|
+
.filter((m) => m !== undefined);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Edits a queued message by its ID.
|
|
385
|
+
* @param messageId The ID of the queued message to edit
|
|
386
|
+
* @param newBody The new body of the message
|
|
387
|
+
*/
|
|
388
|
+
editQueuedMessage(messageId, newBody) {
|
|
389
|
+
const queue = [...this._messageQueue];
|
|
390
|
+
const index = queue.findIndex(m => m.id === messageId);
|
|
391
|
+
if (index !== -1) {
|
|
392
|
+
queue[index] = { ...queue[index], body: newBody };
|
|
393
|
+
this.messageQueue = queue;
|
|
394
|
+
}
|
|
368
395
|
}
|
|
369
396
|
/**
|
|
370
397
|
* Save the chat as json file.
|
|
@@ -433,7 +460,7 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
433
460
|
}
|
|
434
461
|
}
|
|
435
462
|
else if (!silent) {
|
|
436
|
-
console.log(`Provider not
|
|
463
|
+
console.log(`Provider not provided when restoring ${filepath}.`);
|
|
437
464
|
}
|
|
438
465
|
const messages = content.messages.map(message => {
|
|
439
466
|
let attachments = [];
|
|
@@ -637,6 +664,7 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
637
664
|
this.messageAdded(aiMessage);
|
|
638
665
|
this._currentStreamingMessage =
|
|
639
666
|
this.messages.find(message => message.id === aiMessage.id) ?? null;
|
|
667
|
+
this._updateQueueUI();
|
|
640
668
|
}
|
|
641
669
|
/**
|
|
642
670
|
* Handles streaming message chunks from the AI agent.
|
|
@@ -773,6 +801,7 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
773
801
|
raw_time: false
|
|
774
802
|
};
|
|
775
803
|
this.messageAdded(toolCallMessage);
|
|
804
|
+
this._updateQueueUI();
|
|
776
805
|
}
|
|
777
806
|
/**
|
|
778
807
|
* Handles the completion of a tool call execution.
|
|
@@ -831,6 +860,7 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
831
860
|
type: 'msg',
|
|
832
861
|
raw_time: false
|
|
833
862
|
});
|
|
863
|
+
this._updateQueueUI();
|
|
834
864
|
}
|
|
835
865
|
/**
|
|
836
866
|
* Handles tool approval request events from the AI agent.
|
|
@@ -941,11 +971,11 @@ export class AIChatModel extends AbstractChatModel {
|
|
|
941
971
|
}
|
|
942
972
|
var Private;
|
|
943
973
|
(function (Private) {
|
|
944
|
-
|
|
974
|
+
Private.isPlainObject = (value) => {
|
|
945
975
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
946
976
|
};
|
|
947
|
-
|
|
948
|
-
if (!isPlainObject(value)) {
|
|
977
|
+
Private.isDisplayOutput = (value) => {
|
|
978
|
+
if (!Private.isPlainObject(value)) {
|
|
949
979
|
return false;
|
|
950
980
|
}
|
|
951
981
|
const output = value;
|
|
@@ -953,14 +983,14 @@ var Private;
|
|
|
953
983
|
nbformat.isDisplayUpdate(output) ||
|
|
954
984
|
nbformat.isExecuteResult(output));
|
|
955
985
|
};
|
|
956
|
-
|
|
986
|
+
Private.toMimeBundle = (value, trustedMimeTypes) => {
|
|
957
987
|
const data = value.data;
|
|
958
|
-
if (!isPlainObject(data) || Object.keys(data).length === 0) {
|
|
988
|
+
if (!Private.isPlainObject(data) || Object.keys(data).length === 0) {
|
|
959
989
|
return null;
|
|
960
990
|
}
|
|
961
991
|
return {
|
|
962
992
|
data: data,
|
|
963
|
-
...(isPlainObject(value.metadata)
|
|
993
|
+
...(Private.isPlainObject(value.metadata)
|
|
964
994
|
? { metadata: value.metadata }
|
|
965
995
|
: {}),
|
|
966
996
|
// MIME auto-rendering only runs for explicitly configured command IDs.
|
|
@@ -976,21 +1006,21 @@ var Private;
|
|
|
976
1006
|
* Tool outputs are not guaranteed to be raw Jupyter IOPub messages; they are
|
|
977
1007
|
* often wrapped objects (for example `{ success, result: { outputs: [...] } }`).
|
|
978
1008
|
*/
|
|
979
|
-
|
|
980
|
-
if (isDisplayOutput(value)) {
|
|
1009
|
+
Private.toDisplayOutputs = (value) => {
|
|
1010
|
+
if (Private.isDisplayOutput(value)) {
|
|
981
1011
|
return [value];
|
|
982
1012
|
}
|
|
983
1013
|
if (Array.isArray(value)) {
|
|
984
|
-
return value.filter(isDisplayOutput);
|
|
1014
|
+
return value.filter(Private.isDisplayOutput);
|
|
985
1015
|
}
|
|
986
|
-
if (!isPlainObject(value)) {
|
|
1016
|
+
if (!Private.isPlainObject(value)) {
|
|
987
1017
|
return [];
|
|
988
1018
|
}
|
|
989
1019
|
if (Array.isArray(value.outputs)) {
|
|
990
|
-
return value.outputs.filter(isDisplayOutput);
|
|
1020
|
+
return value.outputs.filter(Private.isDisplayOutput);
|
|
991
1021
|
}
|
|
992
1022
|
if ('result' in value) {
|
|
993
|
-
return toDisplayOutputs(value.result);
|
|
1023
|
+
return Private.toDisplayOutputs(value.result);
|
|
994
1024
|
}
|
|
995
1025
|
return [];
|
|
996
1026
|
};
|
|
@@ -999,10 +1029,10 @@ var Private;
|
|
|
999
1029
|
*/
|
|
1000
1030
|
function extractMimeBundlesFromUnknown(content, options = {}) {
|
|
1001
1031
|
const bundles = [];
|
|
1002
|
-
const outputs = toDisplayOutputs(content);
|
|
1032
|
+
const outputs = Private.toDisplayOutputs(content);
|
|
1003
1033
|
const trustedMimeTypes = new Set(options.trustedMimeTypes ?? []);
|
|
1004
1034
|
for (const output of outputs) {
|
|
1005
|
-
const bundle = toMimeBundle(output, trustedMimeTypes);
|
|
1035
|
+
const bundle = Private.toMimeBundle(output, trustedMimeTypes);
|
|
1006
1036
|
if (bundle) {
|
|
1007
1037
|
bundles.push(bundle);
|
|
1008
1038
|
}
|
|
@@ -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,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
|