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

[v3-dev] Initial migration to jupyterlab-chat #1043

Merged
merged 28 commits into from
Dec 6, 2024

Conversation

brichet
Copy link

@brichet brichet commented Oct 21, 2024

Related to #785 and #862

This PR make use of the collaborative chat in place of the chat integrated in jupyter-ai.

In this first step, both chats co-exist (to be able to compare the features), that's why we can see 2 left panel icons, one for the collaborative chat sidebar and one for the jupyter-ai chat.

Peek 2024-10-21 10-29

Currently, the Jupyternaut personna is connected every chat, and answers to every message in the chat.

Work in progress

  • ability to connect/disconnect the Jupyternaut from a chat
  • show that the Jupyternaut is currently answering

brichet and others added 6 commits September 12, 2024 11:30
* Fix handler methods' parameters

* Add slash commands (autocompletion) to the chat input
* Allow for stream messages

* update jupyter collaborative chat dependency
* Add a menu option to open the AI settings

* Remove the input option from the setting widget
@brichet brichet added the enhancement New feature or request label Oct 21, 2024
@brichet brichet marked this pull request as ready for review October 22, 2024 07:59
@dlqqq dlqqq mentioned this pull request Oct 23, 2024
5 tasks
@brichet brichet changed the title Use jupyterlab-collaborative-chat Use jupyterlab-chat extension Nov 22, 2024
@dlqqq dlqqq self-requested a review December 2, 2024 21:27
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.

@brichet Thanks for contributing this, and for being patient with us as we were very busy for the last few months.

I've tried to test this branch by doing a dev install with jlpm && jlpm build && jlpm dev-install. However, I only see replies in the original Jupyter AI chat, and not chats created through jupyterlab-chat.

Question: Do I need to do anything else to get Jupyter AI working in new chats?

Screenshot:

Screenshot 2024-12-02 at 4 02 44 PM

The server logs also include an error:

[E 2024-12-02 15:59:53.928 ServerApp] Failed to write message
    Traceback (most recent call last):
      File "/Users/dlq/micromamba/envs/jai3/lib/python3.11/site-packages/jupyter_collaboration/handlers.py", line 270, in send
        self.write_message(message, binary=True)
      File "/Users/dlq/micromamba/envs/jai3/lib/python3.11/site-packages/tornado/websocket.py", line 332, in write_message
        raise WebSocketClosedError()
    tornado.websocket.WebSocketClosedError
[I 2024-12-02 15:59:53.955 ServerApp] Request for Y document 'test.chat' with room ID: 41030a07-f29d-4ded-b13b-39dfda2b43bb

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.

Completed an initial review of your PR. The changes are surprisingly small relative to the scope of this PR. Thank you for keeping the changes minimal for the sake of reviewers! 🥇

I haven't reviewed everything, but have left some questions & comments on the areas of the code I found most important.

High-level proposal: I noticed was that many of the backend changes to the Python files centered around forwarding the YChat instance as an argument to many methods in BaseChatHandler. Since we know for certain that we want to support multiple chats, I think it makes sense to make chat handlers non-singletons and allow multiple instances of chat handlers (one per chat). This will allow us to revert the changes to the arguments and simplify this PR.

  • By making chat handlers non-singletons, each chat handler can be passed a ychat: YChat attribute on init, which means that chat handler methods won't require a chat: YChat argument. This is what will allow many of the Python changes to be reverted.
  • If this breaks some chat handlers, that's OK for now. We will improve & fix them later right before the first pre-release.

Next steps:

  • Nicolas: Help verify this PR works, respond to my feedback, and tell me if you're OK with me implementing the high-level proposal above.
  • David: Continue reviewing as time permits, and work on the high-level proposal above if you accept.
  • Nicolas & David: Continue to work together to get this merged by the end of this week.

packages/jupyter-ai/jupyter_ai/extension.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/extension.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/extension.py Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/extension.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/extension.py Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/extension.py Outdated Show resolved Hide resolved
@brichet
Copy link
Author

brichet commented Dec 3, 2024

I've tried to test this branch by doing a dev install with jlpm && jlpm build && jlpm dev-install. However, I only see replies in the original Jupyter AI chat, and not chats created through jupyterlab-chat.

Question: Do I need to do anything else to get Jupyter AI working in new chats?

Sorry for this @dlqqq , my bad.
I did some cleaning on the code last week, and broke the AI connection to the chat.

EDIT: It should be fixed by now.

@brichet
Copy link
Author

brichet commented Dec 3, 2024

Thanks for the review @dlqqq

David: Continue reviewing as time permits, and work on the high-level proposal above if you accept.

Sure 👍

@dlqqq dlqqq changed the title Use jupyterlab-chat extension Initial migration to jupyterlab-chat Dec 4, 2024
@dlqqq dlqqq changed the title Initial migration to jupyterlab-chat [v3-dev] Initial migration to jupyterlab-chat Dec 4, 2024
@dlqqq
Copy link
Member

dlqqq commented Dec 4, 2024

@brichet New PR that implements the high-level proposal I mentioned in my last review: QuantStack#9

* create new set of chat handlers per room

* make YChat an instance attribute on BaseChatHandler

* revert changes to chat handlers

* pre-commit

* use room_id local var

Co-authored-by: Nicolas Brichet <[email protected]>

---------

Co-authored-by: Nicolas Brichet <[email protected]>
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.

@brichet Awesome, this PR looks good to me! Of course we will want to iterate on this, but this is a great start. Thank you for your hard work thus far.

Merging into v3-dev. 🎉

@dlqqq dlqqq merged commit cb04fa4 into jupyterlab:v3-dev Dec 6, 2024
7 of 10 checks passed
@krassowski
Copy link
Member

krassowski commented Dec 6, 2024

Hooray, I guess it's a good time to start working on other items from v3 roadmap? Or do you expect any other larger refactor to land soon?

For context I was holding of with some work to avoid adding another moving part to this migration.

@dlqqq
Copy link
Member

dlqqq commented Dec 7, 2024

@krassowski Hey Mike, thanks for reaching out and being so eager to help! Yes, you can absolutely feel free to collaborate on v3 with us. We welcome your contributions, and appreciate all the work you've done for Jupyter AI so far.

If you are proposing a large change, I do ask that you ping me in a new issue / existing issue and provide a broad high-level outline of your proposal. If we discover in our initial discussion that there may be a better way to implement a change, then having this discussion first would save time for both of us. 🤗

The current plan is to cut a pre-release (alpha.0) by the end of December. The goal of this pre-release is to just reach feature parity with Jupyter AI as it is today, i.e. all of the features we already provide for a single chat should work reasonably for multiple chats in the first pre-release. Until then, Nicolas and I won't be focusing on other items on the roadmap, but we will certainly provide reviews for you.

Hope this helps! Have a great weekend Mike, get some rest. 👋

@brichet
Copy link
Author

brichet commented Dec 9, 2024

Hooray, I guess it's a good time to start working on other items from v3 roadmap? Or do you expect any other larger refactor to land soon?

For context I was holding of with some work to avoid adding another moving part to this migration.

I think that it worth noticing that the v3 branch still includes the old chat, while also using jupyterlab_chat extension (both chat are available). It may be confusing for developers, but can be useful to compare the features in both chats.

I'll work on "cleaning old chat" PR.

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.

3 participants