-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Simplify markdown table generation in magic command - %ai list #1251
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keerthi-swarna Great work! I left some feedback for you below.
One other issue I noticed is that the py-markdown-table
dependency is not available on Conda Forge. Conda Forge is an alternative package registry that allows users to install jupyter-ai
using conda
, mamba
, or micromamba
. We can't merge this PR until that is available on Conda Forge, as otherwise installing Jupyter AI from Conda Forge would be broken.
Creating a new Conda Forge package from an existing PyPI package will be a challenge. I would love for you to own this because it is a great opportunity to develop a unique & useful skill. However, I also understand if you need more time before tackling this. Let's talk about this in our next 1:1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you called out, we need to simplify the Markdown output of %ai list
considerably in order for it to render well within ipython
.
One reason the Markdown table is so complicated is because it is poorly structured. Each row (listing a single provider) actually contains several rows of model IDs in the "model IDs" column. The rows of this table really should just be model IDs, not providers.
Here's how I recommend that we move forward on this:
-
Create 1 Markdown table, where each row is a unique model ID.
-
This table should have 3 columns in this order: "Provider name, model ID, environment variable."
-
The emoji that indicates whether it is set (✅/❌) should be in the "Environment variable" column, i.e. we should merge these 2 columns into 1 to save horizontal space.
# Generate markdown table for aliases | ||
alias_markdown_table_header = "\n\n Aliases and custom commands:\n" | ||
alias_markdown_table = ( | ||
markdown_table(alias_list) | ||
.set_params(quote=False, row_sep="markdown") | ||
.get_markdown() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keerthi-swarna Thanks for diving deep and experimenting. In the _ai_list_command_markdown()
method, we use row_sep="markdown"
to strictly follow the Markdown spec and allow JupyterLab to render our table in the browser. However, this fails for tables with large columns (like bedrock-custom
) when displayed in IPython, since we show the literal string value of the table there.
To render a table row with a very long string in one column in IPython, you could explore using py_markdown_table
and set row_sep="always"
in _ai_list_command_text()
. This would allow for table rows to occupy multiple lines, which would solve the issue you're reporting in IPython. The documentation page includes examples of how setting row_sep="always"
can produce readable large tables in IPython. Can you try that and let me know how it goes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. But still it has some issues with help text being displayed. Let us have a working session offline and close this discussion.
Issue Reference: Issue-118
Description
Refactored the code responsible for generating markdown tables by replacing custom imperative logic with the py-markdown-table library.
Changes
_ai_list_command_markdown
method inmagics.py
to generate markdown tables using the py-markdown-table library._ai_env_status_for_provider_markdown
method to return theenv_variable
alongside its status in emoji form, replacing the previous approach where the emoji was appended to theenv_variable
string.py-markdown-table
library as a dependency inpyproject.toml
.aws.py
file to address an issue where markdown was not rendering correctly within a markdown table cell. To resolve this, markdown syntax was replaced with HTML tags to ensure proper rendering.Testing