Skip to content

Commit

Permalink
Fixes double call to cell help command (jupyterlab#220)
Browse files Browse the repository at this point in the history
* Fixes double call to cell help command

* Parity between %ai --help and %ai help

* Revert nonfunctional change
  • Loading branch information
JasonWeill authored and Marchlak committed Oct 28, 2024
1 parent 137cc57 commit bc88dfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
30 changes: 12 additions & 18 deletions examples/commands.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,18 @@
" -r, --reset Clears the conversation transcript used when\n",
" interacting with an OpenAI chat model\n",
" provider. Does nothing with other providers.\n",
" --help Show this message and exit.\n",
"------------------------------------------------------------------------------\n",
"Usage: %%ai [OPTIONS] MODEL_ID\n",
"\n",
" Invokes a language model identified by MODEL_ID, with the prompt being\n",
" contained in all lines after the first. Both local model IDs and global\n",
" model IDs (with the provider ID explicitly prefixed, followed by a colon)\n",
" are accepted.\n",
"\n",
" To view available language models, please run `%ai list`.\n",
"\n",
"Options:\n",
" -f, --format [code|html|image|json|markdown|math|md|text]\n",
" IPython display to use when rendering\n",
" output. [default=\"markdown\"]\n",
" -r, --reset Clears the conversation transcript used when\n",
" interacting with an OpenAI chat model\n",
" provider. Does nothing with other providers.\n",
" -n, --region-name TEXT AWS region name, e.g. 'us-east-1'. Required\n",
" for SageMaker provider; does nothing with\n",
" other providers.\n",
" -q, --request-schema TEXT The JSON object the endpoint expects, with\n",
" the prompt being substituted into any value\n",
" that matches the string literal '<prompt>'.\n",
" Required for SageMaker provider; does\n",
" nothing with other providers.\n",
" -p, --response-path TEXT A JSONPath string that retrieves the\n",
" language model's output from the endpoint's\n",
" JSON response. Required for SageMaker\n",
" provider; does nothing with other providers.\n",
" --help Show this message and exit.\n",
"------------------------------------------------------------------------------\n",
"Usage: %ai [OPTIONS] COMMAND [ARGS]...\n",
Expand Down
4 changes: 1 addition & 3 deletions packages/jupyter-ai-magics/jupyter_ai_magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,7 @@ def display_output(self, output, display_format, md):
return output_display

def handle_help(self, _: HelpArgs):
with click.Context(cell_magic_parser, info_name="%%ai") as ctx:
click.echo(cell_magic_parser.get_help(ctx))
click.echo('-' * 78)
# The line parser's help function prints both cell and line help
with click.Context(line_magic_parser, info_name="%ai") as ctx:
click.echo(line_magic_parser.get_help(ctx))

Expand Down

0 comments on commit bc88dfe

Please sign in to comment.