Skip to content

Commit ff9df3e

Browse files
brichetdlqqq
authored andcommitted
Passes the input model to the getChatCommand() method
1 parent 154d999 commit ff9df3e

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

packages/jupyter-chat/src/chat-commands/types.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,15 @@ export interface IChatCommandProvider {
5050
id: string;
5151

5252
/**
53-
* Async function which accepts the current word and returns a list of
53+
* Async function which accepts the input model and returns a list of
5454
* valid chat commands that match the current word. The current word is
5555
* space-separated word at the user's cursor.
56-
*
57-
* TODO: Pass a ChatModel/InputModel instance here to give the command access
58-
* to more than the current word.
5956
*/
60-
getChatCommands(currentWord: string): Promise<ChatCommand[]>;
57+
getChatCommands(inputModel: IInputModel): Promise<ChatCommand[]>;
6158

6259
/**
6360
* Function called when a chat command is run by the user through the chat
6461
* commands menu.
65-
*
66-
* TODO: Pass a ChatModel/InputModel instance here to provide a function to
67-
* replace the current word.
6862
*/
6963
handleChatCommand(
7064
command: ChatCommand,

packages/jupyter-chat/src/components/input/use-chat-commands.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function useChatCommands(
6363
// TODO: optimize performance when this method is truly async
6464
try {
6565
newCommands = newCommands.concat(
66-
await provider.getChatCommands(currentWord)
66+
await provider.getChatCommands(inputModel)
6767
);
6868
} catch (e) {
6969
console.error(

python/jupyterlab-chat/src/chat-commands/providers/emoji.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export class EmojiCommandProvider implements IChatCommandProvider {
4747
// regex used to test the current word
4848
private _regex: RegExp = /^:\w*:?/;
4949

50-
async getChatCommands(currentWord: string) {
51-
const match = currentWord.match(this._regex)?.[0];
50+
async getChatCommands(inputModel: IInputModel) {
51+
const match = inputModel.currentWord?.match(this._regex)?.[0];
5252
if (!match) {
5353
return [];
5454
}

0 commit comments

Comments
 (0)