@jupyter/chat 0.13.0 → 0.14.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.
Files changed (90) hide show
  1. package/lib/active-cell-manager.d.ts +2 -0
  2. package/lib/active-cell-manager.js +7 -2
  3. package/lib/components/avatar.d.ts +20 -0
  4. package/lib/components/avatar.js +29 -0
  5. package/lib/components/chat.d.ts +1 -3
  6. package/lib/components/chat.js +2 -3
  7. package/lib/components/index.d.ts +2 -3
  8. package/lib/components/index.js +2 -3
  9. package/lib/components/input/buttons/send-button.js +15 -5
  10. package/lib/components/{chat-input.d.ts → input/chat-input.d.ts} +3 -3
  11. package/lib/components/{chat-input.js → input/chat-input.js} +7 -4
  12. package/lib/components/input/index.d.ts +1 -0
  13. package/lib/components/input/index.js +1 -0
  14. package/lib/components/input/toolbar-registry.d.ts +6 -0
  15. package/lib/components/input/use-chat-commands.d.ts +1 -1
  16. package/lib/components/input/use-chat-commands.js +23 -12
  17. package/lib/components/messages/footer.d.ts +2 -2
  18. package/lib/components/messages/footer.js +1 -1
  19. package/lib/components/messages/header.d.ts +16 -0
  20. package/lib/components/messages/header.js +85 -0
  21. package/lib/components/messages/index.d.ts +9 -0
  22. package/lib/components/messages/index.js +13 -0
  23. package/lib/components/messages/message-renderer.js +1 -1
  24. package/lib/components/messages/message.d.ts +21 -0
  25. package/lib/components/messages/message.js +102 -0
  26. package/lib/components/messages/messages.d.ts +38 -0
  27. package/lib/components/messages/messages.js +139 -0
  28. package/lib/components/messages/navigation.d.ts +20 -0
  29. package/lib/components/messages/navigation.js +98 -0
  30. package/lib/components/messages/writers.d.ts +16 -0
  31. package/lib/components/messages/writers.js +39 -0
  32. package/lib/context.d.ts +1 -1
  33. package/lib/index.d.ts +2 -6
  34. package/lib/index.js +2 -6
  35. package/lib/{registry.d.ts → registers/attachment-openers.d.ts} +1 -1
  36. package/lib/registers/chat-commands.d.ts +108 -0
  37. package/lib/{chat-commands/registry.js → registers/chat-commands.js} +8 -8
  38. package/lib/{footers/registry.d.ts → registers/footers.d.ts} +30 -5
  39. package/lib/registers/index.d.ts +3 -0
  40. package/lib/{footers → registers}/index.js +3 -2
  41. package/lib/selection-watcher.d.ts +11 -1
  42. package/lib/selection-watcher.js +10 -4
  43. package/lib/widgets/index.d.ts +3 -0
  44. package/lib/{chat-commands → widgets}/index.js +3 -2
  45. package/package.json +3 -1
  46. package/src/active-cell-manager.ts +10 -1
  47. package/src/components/avatar.tsx +68 -0
  48. package/src/components/chat.tsx +11 -6
  49. package/src/components/index.ts +2 -3
  50. package/src/components/input/buttons/send-button.tsx +17 -5
  51. package/src/components/{chat-input.tsx → input/chat-input.tsx} +12 -7
  52. package/src/components/input/index.ts +1 -0
  53. package/src/components/input/toolbar-registry.tsx +6 -0
  54. package/src/components/input/use-chat-commands.tsx +30 -15
  55. package/src/components/messages/footer.tsx +5 -2
  56. package/src/components/messages/header.tsx +133 -0
  57. package/src/components/messages/index.ts +14 -0
  58. package/src/components/messages/message-renderer.tsx +1 -1
  59. package/src/components/messages/message.tsx +156 -0
  60. package/src/components/messages/messages.tsx +218 -0
  61. package/src/components/messages/navigation.tsx +167 -0
  62. package/src/components/messages/welcome.tsx +1 -0
  63. package/src/components/messages/writers.tsx +81 -0
  64. package/src/context.ts +1 -1
  65. package/src/index.ts +2 -6
  66. package/src/{registry.ts → registers/attachment-openers.ts} +2 -1
  67. package/src/registers/chat-commands.ts +142 -0
  68. package/src/{footers/registry.ts → registers/footers.ts} +35 -8
  69. package/src/{footers → registers}/index.ts +3 -2
  70. package/src/selection-watcher.ts +28 -5
  71. package/src/{chat-commands → widgets}/index.ts +3 -2
  72. package/style/chat.css +82 -0
  73. package/lib/chat-commands/index.d.ts +0 -2
  74. package/lib/chat-commands/registry.d.ts +0 -28
  75. package/lib/chat-commands/types.d.ts +0 -52
  76. package/lib/chat-commands/types.js +0 -5
  77. package/lib/components/chat-messages.d.ts +0 -119
  78. package/lib/components/chat-messages.js +0 -446
  79. package/lib/footers/index.d.ts +0 -2
  80. package/lib/footers/types.d.ts +0 -26
  81. package/lib/footers/types.js +0 -5
  82. package/src/chat-commands/registry.ts +0 -60
  83. package/src/chat-commands/types.ts +0 -67
  84. package/src/components/chat-messages.tsx +0 -739
  85. package/src/footers/types.ts +0 -33
  86. package/lib/components/{toolbar.d.ts → messages/toolbar.d.ts} +0 -0
  87. package/lib/components/{toolbar.js → messages/toolbar.js} +0 -0
  88. package/lib/{registry.js → registers/attachment-openers.js} +0 -0
  89. package/lib/{footers/registry.js → registers/footers.js} +4 -4
  90. /package/src/components/{toolbar.tsx → messages/toolbar.tsx} +0 -0
@@ -0,0 +1,81 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ import { Box, Typography } from '@mui/material';
7
+ import React, { useMemo } from 'react';
8
+
9
+ import { Avatar } from '../avatar';
10
+ import { IUser } from '../../types';
11
+
12
+ const WRITERS_CLASS = 'jp-chat-writers';
13
+
14
+ /**
15
+ * The writers component props.
16
+ */
17
+ type writersProps = {
18
+ /**
19
+ * The list of users currently writing.
20
+ */
21
+ writers: IUser[];
22
+ };
23
+
24
+ /**
25
+ * Animated typing indicator component
26
+ */
27
+ const TypingIndicator = (): JSX.Element => (
28
+ <Box className="jp-chat-typing-indicator">
29
+ <span className="jp-chat-typing-dot"></span>
30
+ <span className="jp-chat-typing-dot"></span>
31
+ <span className="jp-chat-typing-dot"></span>
32
+ </Box>
33
+ );
34
+
35
+ /**
36
+ * The writers component, displaying the current writers.
37
+ */
38
+ export function WritingUsersList(props: writersProps): JSX.Element | null {
39
+ const { writers } = props;
40
+
41
+ // Don't render if no writers
42
+ if (writers.length === 0) {
43
+ return null;
44
+ }
45
+
46
+ const writersText = writers.length > 1 ? ' are writing' : ' is writing';
47
+
48
+ const writingUsers: JSX.Element[] = useMemo(
49
+ () =>
50
+ writers.map((writer, index) => (
51
+ <Box key={writer.username || index} className="jp-chat-writer-item">
52
+ <Avatar user={writer} small />
53
+ <Typography variant="body2" className="jp-chat-writer-name">
54
+ {writer.display_name ??
55
+ writer.name ??
56
+ (writer.username || 'User undefined')}
57
+ </Typography>
58
+ {index < writers.length - 1 && (
59
+ <Typography variant="body2" className="jp-chat-writer-separator">
60
+ {index < writers.length - 2 ? ', ' : ' and '}
61
+ </Typography>
62
+ )}
63
+ </Box>
64
+ )),
65
+ [writers]
66
+ );
67
+
68
+ return (
69
+ <Box className={`${WRITERS_CLASS}`}>
70
+ <Box className="jp-chat-writers-content">
71
+ {writingUsers}
72
+ <Box className="jp-chat-writing-status">
73
+ <Typography variant="body2" className="jp-chat-writing-text">
74
+ {writersText}
75
+ </Typography>
76
+ <TypingIndicator />
77
+ </Box>
78
+ </Box>
79
+ </Box>
80
+ );
81
+ }
package/src/context.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  import { createContext } from 'react';
6
- import { IAttachmentOpenerRegistry } from './registry';
6
+ import { IAttachmentOpenerRegistry } from './registers';
7
7
 
8
8
  export const AttachmentOpenerContext = createContext<
9
9
  IAttachmentOpenerRegistry | undefined
package/src/index.ts CHANGED
@@ -4,16 +4,12 @@
4
4
  */
5
5
 
6
6
  export * from './active-cell-manager';
7
- export * from './chat-commands';
8
7
  export * from './components';
9
- export * from './footers';
10
8
  export * from './icons';
11
9
  export * from './input-model';
12
10
  export * from './markdown-renderer';
13
11
  export * from './model';
14
- export * from './registry';
12
+ export * from './registers';
15
13
  export * from './selection-watcher';
16
14
  export * from './types';
17
- export * from './widgets/chat-error';
18
- export * from './widgets/chat-sidebar';
19
- export * from './widgets/chat-widget';
15
+ export * from './widgets';
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Jupyter Development Team.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
+
5
6
  import { Token } from '@lumino/coreutils';
6
- import { IAttachment } from './types';
7
+ import { IAttachment } from '../types';
7
8
 
8
9
  /**
9
10
  * The token for the attachments opener registry, which can be provided by an extension
@@ -0,0 +1,142 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ import { LabIcon } from '@jupyterlab/ui-components';
7
+ import { Token } from '@lumino/coreutils';
8
+ import { IInputModel } from '../input-model';
9
+
10
+ /**
11
+ * The token for the chat command registry, which can be provided by an extension
12
+ * using @jupyter/chat package.
13
+ */
14
+ export const IChatCommandRegistry = new Token<IChatCommandRegistry>(
15
+ '@jupyter/chat:IChatCommandRegistry'
16
+ );
17
+
18
+ /**
19
+ * Interface of a chat command registry, which tracks a list of chat command
20
+ * providers. Providers provide a list of commands given a user's partial input,
21
+ * and define how commands are handled when accepted in the chat commands menu.
22
+ */
23
+ export interface IChatCommandRegistry {
24
+ /**
25
+ * Adds a chat command provider to the registry.
26
+ */
27
+ addProvider(provider: IChatCommandProvider): void;
28
+
29
+ /**
30
+ * Lists all chat command providers previously added via `addProvider()`.
31
+ */
32
+ getProviders(): IChatCommandProvider[];
33
+
34
+ /**
35
+ * Calls `onSubmit()` on each command provider in serial. Each command
36
+ * provider's `onSubmit()` method is responsible for checking the entire input
37
+ * for command calls and handling them accordingly.
38
+ *
39
+ * This method is called by the application after the user presses the "Send"
40
+ * button but before the message is sent to server.
41
+ */
42
+ onSubmit(inputModel: IInputModel): Promise<void>;
43
+ }
44
+
45
+ export type ChatCommand = {
46
+ /**
47
+ * The name of the command. This defines what the user should type in the
48
+ * input to have the command appear in the chat commands menu.
49
+ */
50
+ name: string;
51
+
52
+ /**
53
+ * ID of the provider the command originated from.
54
+ */
55
+ providerId: string;
56
+
57
+ /**
58
+ * If set, this will be rendered as the icon for the command in the chat
59
+ * commands menu. Jupyter Chat will choose a default if this is unset.
60
+ */
61
+ icon?: LabIcon | JSX.Element | string | null;
62
+
63
+ /**
64
+ * If set, this will be rendered as the description for the command in the
65
+ * chat commands menu. Jupyter Chat will choose a default if this is unset.
66
+ */
67
+ description?: string;
68
+
69
+ /**
70
+ * If set, Jupyter Chat will replace the current word with this string immediately when
71
+ * the command is accepted from the chat commands menu or the current word
72
+ * matches the command's `name` exactly.
73
+ *
74
+ * This is generally used by "shortcut command" providers, e.g. the emoji
75
+ * command provider.
76
+ */
77
+ replaceWith?: string;
78
+
79
+ /**
80
+ * Specifies whether the application should add a space ' ' after the command
81
+ * is accepted from the menu. This should be set to `true` if the command that
82
+ * replaces the current word needs to be handled on submit, and the command is
83
+ * valid on its own.
84
+ *
85
+ * Defaults to `false`.
86
+ */
87
+ spaceOnAccept?: boolean;
88
+ };
89
+
90
+ /**
91
+ * Interface of a command provider.
92
+ */
93
+ export interface IChatCommandProvider {
94
+ /**
95
+ * ID of this command provider.
96
+ */
97
+ id: string;
98
+
99
+ /**
100
+ * A method that should return the list of valid chat commands whose names
101
+ * complete the current word.
102
+ *
103
+ * The current word should be accessed from `inputModel.currentWord`.
104
+ */
105
+ listCommandCompletions(inputModel: IInputModel): Promise<ChatCommand[]>;
106
+
107
+ /**
108
+ * A method that should identify and handle *all* command calls within a
109
+ * message that the user intends to submit. This method is called after a user
110
+ * presses the "Send" button but before the message is sent to the server.
111
+ *
112
+ * The entire message should be read from `inputModel.value`. This method may
113
+ * modify the new message before submission by setting `inputModel.value` or
114
+ * by calling other methods available on `inputModel`.
115
+ */
116
+ onSubmit(inputModel: IInputModel): Promise<void>;
117
+ }
118
+
119
+ /**
120
+ * Default chat command registry implementation.
121
+ */
122
+ export class ChatCommandRegistry implements IChatCommandRegistry {
123
+ constructor() {
124
+ this._providers = new Map<string, IChatCommandProvider>();
125
+ }
126
+
127
+ addProvider(provider: IChatCommandProvider): void {
128
+ this._providers.set(provider.id, provider);
129
+ }
130
+
131
+ getProviders(): IChatCommandProvider[] {
132
+ return Array.from(this._providers.values());
133
+ }
134
+
135
+ async onSubmit(inputModel: IInputModel) {
136
+ for (const provider of this._providers.values()) {
137
+ await provider.onSubmit(inputModel);
138
+ }
139
+ }
140
+
141
+ private _providers: Map<string, IChatCommandProvider>;
142
+ }
@@ -4,7 +4,15 @@
4
4
  */
5
5
 
6
6
  import { Token } from '@lumino/coreutils';
7
- import { MessageFooter, MessageFooterSection } from './types';
7
+ import { IChatModel } from '../model';
8
+ import { IChatMessage } from '../types';
9
+
10
+ /**
11
+ * The token providing the chat footer registry.
12
+ */
13
+ export const IMessageFooterRegistry = new Token<IMessageFooterRegistry>(
14
+ '@jupyter/chat:ChatFooterRegistry'
15
+ );
8
16
 
9
17
  /**
10
18
  * The interface of a registry to provide chat footer.
@@ -22,6 +30,32 @@ export interface IMessageFooterRegistry {
22
30
  addSection(section: MessageFooterSection): void;
23
31
  }
24
32
 
33
+ /**
34
+ * The props sent passed to each `MessageFooterSection` React component.
35
+ */
36
+ export type MessageFooterSectionProps = {
37
+ model: IChatModel;
38
+ message: IChatMessage;
39
+ };
40
+
41
+ /**
42
+ * A message footer section which can be added to the footer registry.
43
+ */
44
+ export type MessageFooterSection = {
45
+ component: React.FC<MessageFooterSectionProps>;
46
+ position: 'left' | 'center' | 'right';
47
+ };
48
+
49
+ /**
50
+ * The message footer returned by the registry, composed of 'left', 'center',
51
+ * and 'right' sections.
52
+ */
53
+ export type MessageFooter = {
54
+ left?: MessageFooterSection;
55
+ center?: MessageFooterSection;
56
+ right?: MessageFooterSection;
57
+ };
58
+
25
59
  /**
26
60
  * The default implementation of the message footer registry.
27
61
  */
@@ -43,10 +77,3 @@ export class MessageFooterRegistry implements IMessageFooterRegistry {
43
77
 
44
78
  private _footers: MessageFooter = {};
45
79
  }
46
-
47
- /**
48
- * The token providing the chat footer registry.
49
- */
50
- export const IMessageFooterRegistry = new Token<IMessageFooterRegistry>(
51
- '@jupyter/chat:ChatFooterRegistry'
52
- );
@@ -3,5 +3,6 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
- export * from './registry';
7
- export * from './types';
6
+ export * from './attachment-openers';
7
+ export * from './chat-commands';
8
+ export * from './footers';
@@ -6,6 +6,10 @@
6
6
  import { JupyterFrontEnd } from '@jupyterlab/application';
7
7
  import { DocumentWidget } from '@jupyterlab/docregistry';
8
8
  import { CodeEditor } from '@jupyterlab/codeeditor';
9
+ import {
10
+ EditorLanguageRegistry,
11
+ IEditorLanguageRegistry
12
+ } from '@jupyterlab/codemirror';
9
13
  import { Notebook } from '@jupyterlab/notebook';
10
14
 
11
15
  import { find } from '@lumino/algorithm';
@@ -26,6 +30,10 @@ export namespace SelectionWatcher {
26
30
  * The current shell of the application.
27
31
  */
28
32
  shell: JupyterFrontEnd.IShell;
33
+ /**
34
+ * Editor language registry.
35
+ */
36
+ languages?: IEditorLanguageRegistry;
29
37
  }
30
38
 
31
39
  /**
@@ -44,6 +52,10 @@ export namespace SelectionWatcher {
44
52
  * The ID of the document widget in which the selection was made.
45
53
  */
46
54
  widgetId: string;
55
+ /**
56
+ * The language of the selection.
57
+ */
58
+ language?: string;
47
59
  /**
48
60
  * The ID of the cell in which the selection was made, if the original widget
49
61
  * was a notebook.
@@ -70,6 +82,7 @@ export interface ISelectionWatcher {
70
82
  export class SelectionWatcher {
71
83
  constructor(options: SelectionWatcher.IOptions) {
72
84
  this._shell = options.shell;
85
+ this._languages = options.languages || new EditorLanguageRegistry();
73
86
  this._shell.currentChanged?.connect((sender, args) => {
74
87
  // Do not change the main area widget if the new one has no editor, for example
75
88
  // a chat panel. However, the selected text is only available if the main area
@@ -149,12 +162,15 @@ export class SelectionWatcher {
149
162
  editor.setSelection({ start: newPosition, end: newPosition });
150
163
  }
151
164
 
152
- protected _poll(): void {
165
+ protected async _poll(): Promise<void> {
153
166
  let currSelection: SelectionWatcher.Selection | null = null;
154
167
  const prevSelection = this._selection;
155
168
  // Do not return selected text if the main area widget is hidden.
156
169
  if (this._mainAreaDocumentWidget?.isVisible) {
157
- currSelection = getTextSelection(this._mainAreaDocumentWidget);
170
+ currSelection = await getTextSelection(
171
+ this._mainAreaDocumentWidget,
172
+ this._languages
173
+ );
158
174
  }
159
175
  if (prevSelection?.text !== currSelection?.text) {
160
176
  this._selection = currSelection;
@@ -169,14 +185,16 @@ export class SelectionWatcher {
169
185
  this,
170
186
  SelectionWatcher.Selection | null
171
187
  >(this);
188
+ private _languages: IEditorLanguageRegistry;
172
189
  }
173
190
 
174
191
  /**
175
192
  * Gets a Selection object from a document widget. Returns `null` if unable.
176
193
  */
177
- function getTextSelection(
178
- widget: Widget | null
179
- ): SelectionWatcher.Selection | null {
194
+ async function getTextSelection(
195
+ widget: Widget | null,
196
+ languages: IEditorLanguageRegistry
197
+ ): Promise<SelectionWatcher.Selection | null> {
180
198
  const editor = getEditor(widget);
181
199
  // widget type check is redundant but hints the type to TypeScript
182
200
  if (!editor || !(widget instanceof DocumentWidget)) {
@@ -207,6 +225,7 @@ function getTextSelection(
207
225
  [start, end] = [end, start];
208
226
  }
209
227
 
228
+ const language = (await languages.getLanguage(editor?.model.mimeType))?.name;
210
229
  return {
211
230
  ...selectionObj,
212
231
  start,
@@ -214,6 +233,10 @@ function getTextSelection(
214
233
  text,
215
234
  numLines: text.split('\n').length,
216
235
  widgetId: widget.id,
236
+
237
+ ...(language && {
238
+ language
239
+ }),
217
240
  ...(cellId && {
218
241
  cellId
219
242
  })
@@ -3,5 +3,6 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
- export * from './types';
7
- export * from './registry';
6
+ export * from './chat-error';
7
+ export * from './chat-sidebar';
8
+ export * from './chat-widget';
package/style/chat.css CHANGED
@@ -78,6 +78,88 @@
78
78
  .jp-chat-writers {
79
79
  display: flex;
80
80
  flex-wrap: wrap;
81
+ position: sticky;
82
+ bottom: 0;
83
+ padding: 8px;
84
+ background-color: var(--jp-layout-color0);
85
+ border-top: 1px solid var(--jp-border-color2);
86
+ z-index: 1;
87
+ }
88
+
89
+ .jp-chat-writers-content {
90
+ display: flex;
91
+ align-items: center;
92
+ gap: 4px;
93
+ flex-wrap: wrap;
94
+ }
95
+
96
+ .jp-chat-writer-item {
97
+ display: flex;
98
+ align-items: center;
99
+ gap: 6px;
100
+ }
101
+
102
+ .jp-chat-writer-name {
103
+ color: var(--jp-ui-font-color1);
104
+ font-weight: 500;
105
+ }
106
+
107
+ .jp-chat-writer-separator {
108
+ color: var(--jp-ui-font-color2);
109
+ }
110
+
111
+ .jp-chat-writing-status {
112
+ display: flex;
113
+ align-items: center;
114
+ gap: 8px;
115
+ }
116
+
117
+ .jp-chat-writing-text {
118
+ color: var(--jp-ui-font-color2);
119
+ }
120
+
121
+ /* Animated typing indicator */
122
+ .jp-chat-typing-indicator {
123
+ display: flex;
124
+ align-items: center;
125
+ gap: 2px;
126
+ padding: 2px 4px;
127
+ }
128
+
129
+ .jp-chat-typing-dot {
130
+ width: 4px;
131
+ height: 4px;
132
+ border-radius: 50%;
133
+ background-color: var(--jp-brand-color1);
134
+ animation: jp-chat-typing-bounce 1.4s infinite ease-in-out;
135
+ }
136
+
137
+ .jp-chat-typing-dot:nth-child(1) {
138
+ animation-delay: -0.32s;
139
+ }
140
+
141
+ .jp-chat-typing-dot:nth-child(2) {
142
+ animation-delay: -0.16s;
143
+ }
144
+
145
+ .jp-chat-typing-dot:nth-child(3) {
146
+ animation-delay: 0s;
147
+ }
148
+
149
+ /* Keyframe animations */
150
+
151
+ @keyframes jp-chat-typing-bounce {
152
+ 0%,
153
+ 80%,
154
+ 100% {
155
+ transform: scale(0.8);
156
+ opacity: 0.5;
157
+ }
158
+
159
+ 40% {
160
+ transform: scale(1.2);
161
+ opacity: 1;
162
+ }
81
163
  }
82
164
 
83
165
  .jp-chat-writers > div {
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './registry';
@@ -1,28 +0,0 @@
1
- import { Token } from '@lumino/coreutils';
2
- import { ChatCommand, IChatCommandProvider } from './types';
3
- import { IInputModel } from '../input-model';
4
- /**
5
- * Interface of a chat command registry, which tracks a list of chat command
6
- * providers. Providers provide a list of commands given a user's partial input,
7
- * and define how commands are handled when accepted in the chat commands menu.
8
- */
9
- export interface IChatCommandRegistry {
10
- addProvider(provider: IChatCommandProvider): void;
11
- getProviders(): IChatCommandProvider[];
12
- /**
13
- * Handles a chat command by calling `handleChatCommand()` on the provider
14
- * corresponding to this chat command.
15
- */
16
- handleChatCommand(command: ChatCommand, inputModel: IInputModel): void;
17
- }
18
- /**
19
- * Default chat command registry implementation.
20
- */
21
- export declare class ChatCommandRegistry implements IChatCommandRegistry {
22
- constructor();
23
- addProvider(provider: IChatCommandProvider): void;
24
- getProviders(): IChatCommandProvider[];
25
- handleChatCommand(command: ChatCommand, inputModel: IInputModel): void;
26
- private _providers;
27
- }
28
- export declare const IChatCommandRegistry: Token<IChatCommandRegistry>;
@@ -1,52 +0,0 @@
1
- /// <reference types="react" />
2
- import { LabIcon } from '@jupyterlab/ui-components';
3
- import { IInputModel } from '../input-model';
4
- export type ChatCommand = {
5
- /**
6
- * The name of the command. This defines what the user should type in the
7
- * input to have the command appear in the chat commands menu.
8
- */
9
- name: string;
10
- /**
11
- * ID of the provider the command originated from.
12
- */
13
- providerId: string;
14
- /**
15
- * If set, this will be rendered as the icon for the command in the chat
16
- * commands menu. Jupyter Chat will choose a default if this is unset.
17
- */
18
- icon?: LabIcon | JSX.Element | string | null;
19
- /**
20
- * If set, this will be rendered as the description for the command in the
21
- * chat commands menu. Jupyter Chat will choose a default if this is unset.
22
- */
23
- description?: string;
24
- /**
25
- * If set, Jupyter Chat will replace the current word with this string after
26
- * the command is run from the chat commands menu.
27
- *
28
- * If all commands from a provider have this property set, then
29
- * `handleChatCommands()` can just return on the first line.
30
- */
31
- replaceWith?: string;
32
- };
33
- /**
34
- * Interface of a command provider.
35
- */
36
- export interface IChatCommandProvider {
37
- /**
38
- * ID of this command provider.
39
- */
40
- id: string;
41
- /**
42
- * Async function which accepts the input model and returns a list of
43
- * valid chat commands that match the current word. The current word is
44
- * space-separated word at the user's cursor.
45
- */
46
- getChatCommands(inputModel: IInputModel): Promise<ChatCommand[]>;
47
- /**
48
- * Function called when a chat command is run by the user through the chat
49
- * commands menu.
50
- */
51
- handleChatCommand(command: ChatCommand, inputModel: IInputModel): Promise<void>;
52
- }
@@ -1,5 +0,0 @@
1
- /*
2
- * Copyright (c) Jupyter Development Team.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- export {};