-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
Migrate streaming logic to BaseChatHandler
#1039
Conversation
Hello, good afternoon. I would like to be unsuscribed from this group,
please. I am receiving too many emails every day. Please.
Kind regards,
Christopher Anich.
…On Fri 18 Oct 2024, 23:49 david qiu, ***@***.***> wrote:
Description
- Migrates streaming logic from DefaultChatHandler to BaseChatHandler,
"lifting up" the implementation such that it can be re-used by different
child classes.
- This will allow for streaming support in other slash commands we
provide, e.g. /ask and /fix.
- This will also allow developers using custom slash commands to
re-use our streaming logic, which will stay updated when jupyter_ai is
upgraded.
- The new "stop streaming" feature introduced by #1022
<#1022> required
changes to the streaming logic, meaning that this feature will not work for
existing custom slash commands that implement streaming. Developers will
have to manually intervene if they want their slash commands to be
stoppable after upgrading to v2.26.0.
- This change will prevent this scenario from happening again in
the future.
------------------------------
You can view, comment on, or merge this pull request online at:
#1039
Commit Summary
- 7107bfe
<7107bfe>
migrate streaming logic to `BaseChatHandler`
- f533e7f
<f533e7f>
add ignore comments to resolve `mypy` errors
- 388b0bb
<388b0bb>
pre-commit
- 2b1083b
<2b1083b>
revert change to LLMChain import module
File Changes
(4 files <https://github.com/jupyterlab/jupyter-ai/pull/1039/files>)
- *M* packages/jupyter-ai/jupyter_ai/chat_handlers/ask.py
<https://github.com/jupyterlab/jupyter-ai/pull/1039/files#diff-6e09b53257fc99bac8b132e61531175e798c65fd107844c4d21c4754b2bb71ae>
(6)
- *M* packages/jupyter-ai/jupyter_ai/chat_handlers/base.py
<https://github.com/jupyterlab/jupyter-ai/pull/1039/files#diff-e164ea9ccdd1b4c56ee5e6cdf7d4bc838cccd88f7fdb7f447332a21565d2803f>
(143)
- *M* packages/jupyter-ai/jupyter_ai/chat_handlers/default.py
<https://github.com/jupyterlab/jupyter-ai/pull/1039/files#diff-61b6ffc90741cf3d7ba3038ef6a0ea0d28645adf64ce247a4420f711048dde2d>
(118)
- *M* packages/jupyter-ai/jupyter_ai/chat_handlers/fix.py
<https://github.com/jupyterlab/jupyter-ai/pull/1039/files#diff-e97a377cfc1eba64e747e0ec74570ac8eb952599b5a9d7020de57b089c661026>
(10)
Patch Links:
- https://github.com/jupyterlab/jupyter-ai/pull/1039.patch
- https://github.com/jupyterlab/jupyter-ai/pull/1039.diff
—
Reply to this email directly, view it on GitHub
<#1039>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A77O7PTALUJVJ5RPYPZE6YDZ4GF6VAVCNFSM6AAAAABQG2KEQKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4TQNJRGI3TMNI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
stream_id: str, | ||
content: str, | ||
complete: bool = False, | ||
metadata: Dict[str, Any] = {}, |
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.
Just highlighting a pre-existing potential issue here (https://florimond.dev/en/posts/2018/08/python-mutable-defaults-are-the-source-of-all-evil)
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.
Thanks for calling this out! I'll update the code & keep this mind in the future.
It would be better if there was some automated method of catching this for other devs. Do you know of any linter that can flag mutable default arguments?
2b1083b
to
dff511e
Compare
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.
I tested this PR. Code seems good as well, the transfer from default.py
to base.py
is useful and a good refactor for future development.
- Standard streaming response works as expected.
- Streaming with
@file
also works as expected. - Streaming with
/ask
and/fix
not implemented and is unaffected. Placeholder for these with runnable are appropriately placed in the code.
* migrate streaming logic to `BaseChatHandler` * add ignore comments to resolve `mypy` errors * pre-commit * revert change to LLMChain import module * drop mutable default argument
Description
DefaultChatHandler
toBaseChatHandler
, "lifting up" the implementation such that it can be re-used by different child classes./ask
and/fix
.jupyter_ai
is upgraded.Follow-up issues
Issues that should be addressed after this PR is merged & released (in descending priority).
/ask
#863/fix
#1041