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

Migrate streaming logic to BaseChatHandler #1039

Merged
merged 5 commits into from
Oct 21, 2024

Conversation

dlqqq
Copy link
Member

@dlqqq dlqqq commented Oct 18, 2024

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 Allow users to stop message streaming #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.

Follow-up issues

Issues that should be addressed after this PR is merged & released (in descending priority).

@chrisanich
Copy link

chrisanich commented Oct 19, 2024 via email

@srdas
Copy link
Collaborator

srdas commented Oct 19, 2024

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.
@chrisanich You can "unwatch" the repo, hope this helps.
image

stream_id: str,
content: str,
complete: bool = False,
metadata: Dict[str, Any] = {},
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

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?

Copy link
Collaborator

@srdas srdas left a 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.

  1. Standard streaming response works as expected.
  2. Streaming with @file also works as expected.
  3. Streaming with /ask and /fix not implemented and is unaffected. Placeholder for these with runnable are appropriately placed in the code.

@dlqqq dlqqq merged commit 2545fd1 into jupyterlab:main Oct 21, 2024
10 checks passed
Marchlak pushed a commit to Marchlak/jupyter-ai that referenced this pull request Oct 28, 2024
* migrate streaming logic to `BaseChatHandler`

* add ignore comments to resolve `mypy` errors

* pre-commit

* revert change to LLMChain import module

* drop mutable default argument
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.

4 participants