Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds %ai list, %ai help magic commands #100

Merged
merged 18 commits into from
Apr 25, 2023

Conversation

JasonWeill
Copy link
Collaborator

@JasonWeill JasonWeill commented Apr 20, 2023

Fixes #28.

Defines %ai help and %ai list magic commands. The latter displays all model providers and, if possible, individual models in a format suitable for copying into a code cell. %ai list takes an optional parameter of a model provider ID.

This feature works in both IPython terminals:

In [2]: %ai list
Out[2]: 
ai21
Requires environment variable AI21_API_KEY (not set)
* ai21:j1-large
* ai21:j1-grande
* ai21:j1-jumbo
* ai21:j1-grande-instruct
* ai21:j2-large
* ai21:j2-grande
* ai21:j2-jumbo
* ai21:j2-grande-instruct
* ai21:j2-jumbo-instruct

anthropic
Requires environment variable ANTHROPIC_API_KEY (not set)
* anthropic:claude-v1
* anthropic:claude-v1.0
* anthropic:claude-v1.2
* anthropic:claude-instant-v1
* anthropic:claude-instant-v1.0

cohere
Requires environment variable COHERE_API_KEY (not set)
* cohere:medium
* cohere:xlarge

huggingface_hub
Requires environment variable HUGGINGFACEHUB_API_TOKEN (not set)
* This provider does not define a list of models.

openai
Requires environment variable OPENAI_API_KEY (not set)
* openai:text-davinci-003
* openai:text-davinci-002
* openai:text-curie-001
* openai:text-babbage-001
* openai:text-ada-001
* openai:davinci
* openai:curie
* openai:babbage
* openai:ada

openai-chat
Requires environment variable OPENAI_API_KEY (not set)
* openai-chat:gpt-4
* openai-chat:gpt-4-0314
* openai-chat:gpt-4-32k
* openai-chat:gpt-4-32k-0314
* openai-chat:gpt-3.5-turbo
* openai-chat:gpt-3.5-turbo-0301

sagemaker-endpoint
* This provider does not define a list of models.

… and in JupyterLab:

Screen Shot 2023-04-21 at 2 29 41 PM

Adds a sample notebook and updates the user docs with information about %ai list.

@JasonWeill JasonWeill added enhancement New feature or request @jupyter-ai/magics labels Apr 20, 2023
@ellisonbg
Copy link
Contributor

We have enough, maybe two columns or a table to better utilize the width?

@JasonWeill
Copy link
Collaborator Author

@ellisonbg Markdown doesn't really allow multi-column layouts; how about this layout to include all models in the right column of a 2-column table? (The text output is unchanged.)

image

@JasonWeill
Copy link
Collaborator Author

Updates the Markdown view with a new column, emoji for environment variables being set/not set, and tooltips to describe what these mean.

Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two high-level suggestions in addition to the ones below:

  1. I believe we can leverage an open source solution to generate a plaintext-formatted MD table declaratively rather than constructing it imperatively (row-by-row, column-by-column) like the current implementation. For example, py-markdown-table offers this functionality. Perhaps this can even be used in the IPython view and let you remove the TextAndMarkdown object you're using throughout? 👀 This will also allow you to greatly reduce the number of private methods you're adding onto the AiMagics class 😁

  2. Rather than calling utility functions manually, could you perhaps create a new display object by subclassing IPython.display.DisplayObject, that accepts a 2D array and returns the table as a string? Perhaps this point (2) is a stretch goal; feel free to track this in a separate issue to address later.

packages/jupyter-ai-magics/jupyter_ai_magics/providers.py Outdated Show resolved Hide resolved
packages/jupyter-ai-magics/jupyter_ai_magics/magics.py Outdated Show resolved Hide resolved
packages/jupyter-ai-magics/jupyter_ai_magics/magics.py Outdated Show resolved Hide resolved
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thank you for opening the follow-up items in #117 and #118.

@JasonWeill JasonWeill merged commit 126f35e into jupyterlab:main Apr 25, 2023
dbelgrod pushed a commit to dbelgrod/jupyter-ai that referenced this pull request Jun 10, 2024
* Initial help command support

* Adds help command

* Matches error message

* Styles model ID in error

* Introduces TextWithMarkdown class

* Removes incorrect comment

* Alphabetizes classes

* List of models

* Adds model list

* Documents %ai list

* Optional parameter

* Updates example notebook

* Documents parameter

* In Markdown, displays a table of models

* Adds column for env vars

* Uses emoji in its own column

* Renames class to TextOrMarkdown

* Removes dictionary of env vars
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
* Initial help command support

* Adds help command

* Matches error message

* Styles model ID in error

* Introduces TextWithMarkdown class

* Removes incorrect comment

* Alphabetizes classes

* List of models

* Adds model list

* Documents %ai list

* Optional parameter

* Updates example notebook

* Documents parameter

* In Markdown, displays a table of models

* Adds column for env vars

* Uses emoji in its own column

* Renames class to TextOrMarkdown

* Removes dictionary of env vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request @jupyter-ai/magics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to list all available models I can use with %%ai
3 participants