-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
Add Error Animation in Code Cell for Jupyter-AI Errors #1197
base: main
Are you sure you want to change the base?
Add Error Animation in Code Cell for Jupyter-AI Errors #1197
Conversation
Co-authored-by: Andrew Fulton andrewfulton9@gmail.com
ce9bb53
to
8784c56
Compare
for more information, see https://pre-commit.ci
I think you could override |
I think you will also need to bump the version of jupyterlab/completer to 4.3.0 if the main branch of jupyter-ai isn't on that version yet. It wasn't when I looked at this issue. |
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.
@Darshan808 Welcome to Jupyter AI! I love seeing new contributors. Thank you for getting started on this feature request.
I've left a few suggestions below. In addition, I have a couple of questions:
- Could you add a screenshot to this PR?
- The original issue (Show error animation in code cell when error is triggered #1144) shows an icon when the completer fails. How is the icon being added?
class InlineCompletionError(BaseModel): | ||
message: str | ||
|
||
|
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.
With this PR, it seems like whether an inline completion resulted in an error can be determined in 2 different ways:
-
An error occurred if only one
InlineCompletionItem
is returned andInlineCompletionItem.error
exists. -
An error occurred if
InlineCompletionReply.error
exists.- This attribute takes the type
CompletionError
, which is very similar to theInlineCompletionError
model that you added.CompletionError
is already defined here on line 49.
- This attribute takes the type
I suggest that we:
-
Have a single source of truth and drop either
InlineCompletionItem.error
orInlineCompletionReply.error
. That way, there's only one way to determine if a completion reply has an error. -
Drop either
InlineCompletionError
orCompletionError
, as the models are very similar and can probably be unified.
async def test_handle_request_with_error(inline_handler): | ||
inline_handler = MockCompletionHandler( | ||
lm_provider=MockProvider, | ||
lm_provider_params={ | ||
"model_id": "model", | ||
"responses": ["test"], | ||
}, | ||
) |
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.
Currently seeking guidance on how to simulate error scenarios for testing.
You can modify MockProvider
to take an raise_exc
param. If "raise_exc": True
is set in lm_provider_params
, then MockProvider
should raise an exception in its _call()
method. For example:
def _call(self, *args, **kwargs):
if self.raise_exc:
raise Exception("Test exception")
else:
return super()._call(*args, **kwargs)
In LangChain, LLM._call()
is (usually) the method which is called when a non-streaming reply is requested. If this doesn't work, you can try following the above steps for the _acall()
method instead.
for more information, see https://pre-commit.ci
Thank you for your feedback and suggestions, @dlqqq
Yes, this was redundant, so I dropped
Whenever we return an item with the
Sure, I am adding a clip.
This worked perfectly. |
for more information, see https://pre-commit.ci
A custom error can be raised here before sending the reply. |
The newly added test passes locally but fails on CI. Looking into it |
References #1144
This PR introduces the error animation functionality to code cells for jupyter-ai. It aligns jupyter-ai's error reporting with JupyterLab's completer error animation feature.
error
field in responses from jupyter-ai during error generation.Testing
error
field emission.Feedback on the testing approach is appreciated, particularly on methods to programmatically raise errors during tests.
Screencast
Simulated by raising custom exception from server side
ai-error.mp4