Skip to content

Commit

Permalink
Make path argument required on /learn (#1012)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent 278dede commit 3a6b0f0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,18 @@ async def process_message(self, message: HumanChatMessage):
return

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

0 comments on commit 3a6b0f0

Please sign in to comment.