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 Err array with exceptions captured #34

Merged
merged 22 commits into from
Apr 12, 2023

Conversation

JasonWeill
Copy link
Collaborator

@JasonWeill JasonWeill commented Apr 6, 2023

Fixes #41.

If a particular cell causes an exception, captures the text of the exception in a special Err array, with the same indexing as In and Out.

Handles SyntaxErrors specifically.

image

@dlqqq dlqqq added the enhancement New feature or request label Apr 6, 2023
@JasonWeill
Copy link
Collaborator Author

Improves traceback formatting, adds a workbook. (My local PC isn't set up to actually call ChatGPT yet, though)

@ellisonbg
Copy link
Contributor

Looks like this is not quite functioning as expected yet:

  • The custom handler raises, which disables it for future calls.
  • The handler should return None or a structured traceback. Details can be found here:

https://github.com/ipython/ipython/blob/a418f38c4f96de1755701041fe5d8deffbf906db/IPython/core/interactiveshell.py#L1887

I believe we will need to do everything we need to with Err and then use the standard IPython exception handling logic to return the structured traceback. That handling can be found here:

https://github.com/ipython/ipython/blob/a418f38c4f96de1755701041fe5d8deffbf906db/IPython/core/interactiveshell.py#L2062

@ellisonbg
Copy link
Contributor

Also, the example notebook looks like it isn't resolving the model id.

@dlqqq
Copy link
Member

dlqqq commented Apr 7, 2023

@ellisonbg Can you elaborate more on the model ID resolution issue you are facing?

The implementation didn't respect the model ID for the HuggingFace Hub provider, but that bug should now be fixed in the latest release (0.4.0).

@JasonWeill
Copy link
Collaborator Author

@ellisonbg Can you elaborate more on the model ID resolution issue you are facing?

The implementation didn't respect the model ID for the HuggingFace Hub provider, but that bug should now be fixed in the latest release (0.4.0).

After discussion, the model ID resolution issue was related to an issue with my dev environment; I was still running 0.3.0 code. Rerunning ./scripts/install.sh fixed the issue.

@JasonWeill
Copy link
Collaborator Author

Updated screen shot in original description; shell.showtraceback() in the exception handler seems to pass along the exception with the same experience as before.

@JasonWeill JasonWeill requested a review from ellisonbg April 10, 2023 19:06
@JasonWeill JasonWeill marked this pull request as ready for review April 10, 2023 19:06
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.

This looks great! Left a few comments.

This needs to be reconciled with #48. So exception.py should be moved to packages/jupyter-ai-magics/jupyter_ai_magics, and the load_ipython_extension and unload_ipython_extension functions should be defined there in __init__.py as well.

Then in jupyter_ai, you can declare:

# expose jupyter_ai_magics ipython extension
from jupyter_ai_magics import load_ipython_extension, unload_ipython_extension

These imports expose the extension hooks to IPython in jupyter_ai. 😁

@JasonWeill JasonWeill requested a review from dlqqq April 11, 2023 20:26
@JasonWeill JasonWeill dismissed ellisonbg’s stale review April 12, 2023 01:41

Changes made in subsequent code pushes

@JasonWeill JasonWeill merged commit 83efdeb into jupyterlab:main Apr 12, 2023
dbelgrod pushed a commit to dbelgrod/jupyter-ai that referenced this pull request Jun 10, 2024
* Defines exception handler

* Reraises exception

* More detailed traceback

* Adds improved formatting, example workbook

* Uses chatgpt model

* Uses shell.showtraceback

* Displays traceback info from tb, needs to return a structured traceback

* Returns a list of strings or None

* Shows traceback, updates sample notebook

* Avoids using tb for traceback, updates example notebook

* Mentions jupyter_ai_magics everywhere

* Expose jupyter_ai_magics in jupyter_ai

* Removes unload_ipython_extension

* Removes import of unload

* Simplifies error capture

* Update sample errors doc

* Reinstates jupyter_ai as extension name

* Disables ANSI color strings so that the error is captured in text

* Sample notebook w/non-color error

* Handles syntax errors

* Reinstates unload_ipython_extension

* Reverts _magics from docs
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
* Defines exception handler

* Reraises exception

* More detailed traceback

* Adds improved formatting, example workbook

* Uses chatgpt model

* Uses shell.showtraceback

* Displays traceback info from tb, needs to return a structured traceback

* Returns a list of strings or None

* Shows traceback, updates sample notebook

* Avoids using tb for traceback, updates example notebook

* Mentions jupyter_ai_magics everywhere

* Expose jupyter_ai_magics in jupyter_ai

* Removes unload_ipython_extension

* Removes import of unload

* Simplifies error capture

* Update sample errors doc

* Reinstates jupyter_ai as extension name

* Disables ANSI color strings so that the error is captured in text

* Sample notebook w/non-color error

* Handles syntax errors

* Reinstates unload_ipython_extension

* Reverts _magics from docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Err variable so a user can pass a traceback to the LLM
3 participants