Skip to content

Commit 3a6b0f0

Browse files
andrewfulton9krassowskidlqqq
authored
Make path argument required on /learn (#1012)
* Add dialog pop-up if no parameter is given for /learn * lint and improve wording * Update packages/jupyter-ai/src/components/chat-input.tsx Co-authored-by: Michał Krassowski <[email protected]> * Update packages/jupyter-ai/src/components/chat-input.tsx Co-authored-by: Michał Krassowski <[email protected]> * add else clause * remove warning * /learn arg.path required, remove warning * Update packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py Co-authored-by: Michał Krassowski <[email protected]> * Update packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py Co-authored-by: Michał Krassowski <[email protected]> * Update packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py Co-authored-by: david qiu <[email protected]> * remove debugging print --------- Co-authored-by: Michał Krassowski <[email protected]> Co-authored-by: david qiu <[email protected]>
1 parent 278dede commit 3a6b0f0

File tree

1 file changed

+12
-2
lines changed
  • packages/jupyter-ai/jupyter_ai/chat_handlers

1 file changed

+12
-2
lines changed

packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,18 @@ async def process_message(self, message: HumanChatMessage):
175175
return
176176

177177
# Make sure the path exists.
178-
if not len(args.path) == 1:
179-
self.reply(f"{self.parser.format_usage()}", message)
178+
if not (len(args.path) == 1 and args.path[0]):
179+
no_path_arg_message = (
180+
"Please specify a directory or pattern you would like to "
181+
'learn on. "/learn" supports directories relative to '
182+
"the root (or preferred dir, if set) and Unix-style "
183+
"wildcard matching.\n\n"
184+
"Examples:\n"
185+
"- Learn on the root directory recursively: `/learn .`\n"
186+
"- Learn on files in the root directory: `/learn *`\n"
187+
"- Learn all python files under the root directory recursively: `/learn **/*.py`"
188+
)
189+
self.reply(f"{self.parser.format_usage()}\n\n {no_path_arg_message}")
180190
return
181191
short_path = args.path[0]
182192
load_path = os.path.join(self.output_dir, short_path)

0 commit comments

Comments
 (0)